A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
Im trying to use Fermat's little theorem at first assignment but it doesnt work somehow i realy need some help!
anonymous
 5 years ago
Im trying to use Fermat's little theorem at first assignment but it doesnt work somehow i realy need some help!

This Question is Closed

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0primes=[] n = 0 for p in range (2,150000): if n < 1000: if (2**p2) % p == 0: primes.append(p) n = len (primes) print primes

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0I tried this formula to start with but i get 7741 as the final prime number why its not right?

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0This 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

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0I cant find a solution to exclude them so i will need to find another way i think :/.Thank you for reply!!

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0bugrakokalp: 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.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0This code overlooks the fact that Fermat's primality test is only probabilistic http://en.wikipedia.org/wiki/Fermat_primality_test
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.