Prev: DynatOS 64-bit is here!!!
Next: Slow nasm
From: Terence on 23 Oct 2007 18:53 At least our friend is trying to do his homework! I would have done it differently. 1) set 10000 bit table of words to 1 (1250 bytes of FF) 2) do a loop to turn off every second bit, every third and so on up to 100th (square root of 10,000) in the table. (end of setup) Loop till no more numbers input (e.g, a zero) 3) take in the number to be tested, and find its bit number and see if it is a 1 (prime) or no (not). in the table of bits as byte number and, bit remainder index to 8 possible bit maps( 01,02,04,08,10,20,40,80 hex) 4) if find next one bit up and down from this bit position in the table and report both corresponding prime numbers if index greater than 0 and less than 10000.
From: ravenheart on 24 Oct 2007 17:02
Thanks to you all |