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.
Print out Prime Numbers
' 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
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
Dani 4,346 The Queen of DaniWeb Administrator Featured Poster Premium Member
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.