Reputation: 21
If n
is a positive integer greater than 2 that satifies modp(2^n-1,n)=1
and n
is not prime, then n
is called a 2-pseudoprime. Find all 2-pseudoprimes less than 2000, and for each pseudoprime, output the pseudoprime and the set of its prime divisors.
Here is what I have tried so far. By the way, this is using maple.
for n from 2 to 2000 do
n, mod(2^n-1,n) isprime(n);
od;
I am not sure what else to do here.
Upvotes: 2
Views: 178
Reputation: 7271
What you need is a conditional statement, constructed using if...then...fi
(or the more modern if...then...end if
.)
If the condition is met, then the desired result could be printed.
for n from 2 to 2000 do
if `mod`(2^n-1,n) = 1 and not( isprime(n) ) then
print(n, map(expand,{op(ifactor(n))}));
fi;
od;
Upvotes: 0