I just had to do this to see how it would look like in the code field. This small prime number generator is written in BCX basic, a mildy more modern basic than Qbasic. With BCX basic you can throw in C and assembler code and it would actually compile it. Gives you the familiar comfort of basic, but allows you to venture to C at will.

' look at a series of numbers and print out the prime numbers
' prime numbers are divisible only by unity or themselves
' this is BCX basic, a modern successor to Qbasic

Dim A    ' defaults to integer

For A = 1 To 100
  If IsPrime(A) Then Print A;

Pause   ' make console wait

Function IsPrime(Num)
  Local X
  ' make exeptions for unity and 2
  If Num = 1 Then Function = True
  If Num = 2 Then Function = True
  ' leave on even numbers
  If Mod(Num, 2) = 0 Then Exit Function
  For X = 3 To Num - 1 Step 2
    If Mod(Num, X) = 0 Then Exit Function
  Next X
  Function = TRUE  ' return true if it's a Prime Number
End Function
13 Years
Discussion Span
Last Post by vegaseat

Well, indent doesn't work and highlighting is hit and miss, just like the real Qbasic code snippet.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.