Article ID: 39188
Article Last Modified on 11/21/2006
This article was previously published under Q39188
SUMMARY
On Page 333 of the "Microsoft QuickBASIC for Apple Macintosh: BASIC Language Reference", the TIMER function Example (the Sieve of Eratosthenes benchmark program) is supposed to find prime numbers. However, it mistakenly finds some numbers that are not actually prime.
The Sieve of Eratosthenes benchmark program on Page 333 should be replaced with the version below, which correctly returns only prime numbers.
MORE INFORMATION
The replacement program is as follows:
defint a-z size=8191 dim flags(8191) count=0 for i=2 to size flags(i)=-1 next for i=2 to sqr(size) if flags(i) then for k=i*i to size step i flags(k)=0 next end if next for i=0 to size if flags(i) then print i; : count = count + 1 next print print count; "primes" while mouse(0): wend
Additional query words: MQuickB
Keywords: KB39188