•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Legacy and Other Languages section within the Software Development category of DaniWeb, a massive community of 363,778 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,471 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Legacy and Other Languages advertiser:
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; 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
Comments (Newest First)
vegaseat | Kickbutt Moderator | Jan 9th, 2007
vegaseat | Kickbutt Moderator | Jan 1st, 2005
cscgal | The Queen of DaniWeb | Jan 1st, 2005
•
•
•
•
Working on it
vegaseat | Kickbutt Moderator | Jan 1st, 2005
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)
Any natural number greater than 1 that has the two divisors 1 and itself.
Defined in: http://en.wikipedia.org/wiki/Prime_number