Hi, I'm rather new to Maple but I have to find a composite number n which has the property that all her coprimes a fulfill the expression "a^(n-1) - 1 mod n = 0". I already found out that such numbers are called Carmichael numbers. But of course I need to use Maple and the information I was given by our professor.
My problem is that I have no idea how to check if "a^(n-1) - 1 mod n = 0" is true for all coprimes of a given n. How do I? ;)
btw. I don't know if I used the correct vocabulary here, so please forgive me if I expressed something wrong.
code
Using a translation of the Mma code here to get Carmichael numbers,
> seq(`if`(modp(n,numtheory[lambda](n))=1 and > not isprime(n), n, NULL), n=1..10000); 561, 1105, 1729, 2465, 2821, 6601, 8911See the Comment section at that link.
acer
Thank you, now I just need
Thank you, now I just need to understand how I could've found this myself.
... and ...
And probably the professor wanted *him* to program it, rather than using some pre-programmed "lambda" function.
---
G A Edgar
Hint
The straightforward way (without using lambda), given n, is to start with the
set of integers {$1..n-1}, select those coprime to n (using select and igcd),
and compute a^(n-1) mod n for all those a.
^ That sounds good. I'm
^ That sounds good, I'm going to try it. But why do I only need to check the property for all the coprimes smaller than n? I mean, there is most likely an infinite number of coprimes greater than n, too.
EDIT: I came up with the following code. I bet it's a mess:
Why < n?
Note that if x is congruent to y mod n, then x^k is congruent to y^k mod n. So all you need to check is one member of each congruence class mod n.
Your code could be cleaned up a little, e.g. you might want to use andmap, but basically it's fine.
Thank you, andmap was just
Thank you, andmap was just what I was looking for.