calandale wrote:
http://fpx.de/fp/Software/Sieve.html
as to the savant's, the human brain is very complex. My guess (though I'm no psychologist) is that they have simply made these calculations and memorized them, probably without noticing.
wow for someone who knows c thats a pretty sh***y way to calc prime numbers. this is a program i wrote in VB long time ago (i know vb is less effecent than c, but the overall method i think mine is more effecent)
Code:
Private Sub cmdCalcPrime_Click()
Dim intN As Integer, intI As Integer, intII As Integer
Dim intPrime() As Integer, intPrimeCount As Integer
intN = 2 ^ 15 - 2
ReDim Preserve intPrime(intN) As Integer
intPrime(0) = 2
For intI = 3 To intN Step 2
For intII = 0 To intPrimeCount
If intI Mod intPrime(intII) = 0 Then GoTo NotPrime
Next intII
intPrimeCount = intPrimeCount + 1
intPrime(intPrimeCount) = intI
lstPrime.AddItem CStr(intI), 0
DoEvents
NotPrime:
Next intI
End Sub
i think i was 13-14 when i wrote this (i keep ALLLLL my old source codes) this was before i really knew much VB, if i where to code it now it would be a lot cleaner. anyways this gets all the prime numbers that will fit in an integer. it checks each number is not divisible by all the prime numbers up to it, witch is how i find prime numbers in my head. say a number like 49, it is divisible by 7, no prime. then i see a num like 89, i see no small prime number factors for it. i know the 7 "times tables", and thats the only weird one. so 89 must be prime.
i can count is prime numbers. i go by 2s starting at 3. 3,5,7,9,etc. than each num i see factors for i skip. 3 5 7 11 13 17 19 etc. i start having to really think when i get into 3 digit nums