MIT 6.00 Intro Computer Science (OCW) 26 Online
OpenStudy (anonymous):

Im trying to use Fermat's little theorem at first assignment but it doesnt work somehow i realy need some help!

OpenStudy (anonymous):

primes=[] n = 0 for p in range (2,150000): if n < 1000: if (2**p-2) % p == 0: primes.append(p) n = len (primes) print primes

OpenStudy (anonymous):

I tried this formula to start with but i get 7741 as the final prime number why its not right?

OpenStudy (anonymous):

This is a cool approach I haven't seen before. I didn't know what Fermat's Little Theorem was, but from http://en.wikipedia.org/wiki/Fermat_primality_test, it appears that you're probably also finding Carmichael numbers: http://en.wikipedia.org/wiki/Carmichael_number

OpenStudy (anonymous):

I cant find a solution to exclude them so i will need to find another way i think :/.Thank you for reply!!

OpenStudy (anonymous):

bugrakokalp: When I ran your code, I found there are at least 18 different numbers in your list that are not prime. ex. 341 in your list has 11 and 31 as factors, and hence is not prime. I hope this helps.

OpenStudy (anonymous):

This code overlooks the fact that Fermat's primality test is only probabilistic-- http://en.wikipedia.org/wiki/Fermat_primality_test

Latest Questions
xXAikoXx: I wanna cry so bad
2 minutes ago 2 Replies 0 Medals
kimberlysaavedra: guyss its my birthday tomorrow!!!!!! 8-4-2008
27 minutes ago 14 Replies 0 Medals
TarTar: If you could go back to any year what would you pick and why
1 minute ago 23 Replies 2 Medals
TarTar: Ever been complimented so much you think it's a prankud83dude2d
16 hours ago 2 Replies 0 Medals
Puck: my camera roll right now
11 hours ago 4 Replies 2 Medals
kimberlysaavedra: @cora1
8 hours ago 16 Replies 1 Medal
ShikuniShigana: Should i continue drawing this or redraw it yall?
1 day ago 5 Replies 2 Medals
Leila1234565: Best way to sneak a phone back
1 day ago 1 Reply 0 Medals
niyaaa02: I hate boy bops .
1 day ago 0 Replies 0 Medals