Quote (gramkracka22 @ Oct 10 2013 05:38pm)
2) Need to find a formal algorithm to find prime numbers Mainly looking at like prime numbers under 100 here, using the info That if say 7 is a prime number, you know that all its multiples aren't (14,21,28, etc).
Not the best, but this is one I wrote recently (in python). Prints list of primes from 2 to 100
Code
import math
def IsPrime(input_number):
if input_number == 2:
return True
if not input_number%2:
return False
max = int(math.ceil((math.sqrt(input_number)))+1)
for i in range (3,max,2):
if not input_number%i:
return False
return True
for i in range(2,101):
if IsPrime(i):
print i
This post was edited by Azrad on Oct 10 2013 10:08pm