cscgal
The Queen of DaniWeb
Administrator
19,427 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
' 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;
Next
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