Problem Type : Number Theory
#include<stdio.h>
#include<string.h>
int main()
{
int n,i;
int p;
scanf("%d",&n);
for(i=1; i<=n; i++)
{
scanf("%d,",&p);
if( p == 2 || p == 3 || p == 5 || p == 7 || p == 13 || p == 17 || p == 19 )
printf("Yes") ;
else printf("No");
}
}
Euclid proved that 2p−1(2p − 1) is an even perfect number whenever 2p − 1 is prime (Euclid, Prop. IX.36).
For example, the first four perfect numbers are generated by the formula 2p−1(2p − 1), with p a prime number, as follows:
- for p = 2: 21(22 − 1) = 6
- for p = 3: 22(23 − 1) = 28
- for p = 5: 24(25 − 1) = 496
- for p = 7: 26(27 − 1) = 8128.
- p = 2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583, 25964951, and 30402457
- এই সব Prime number দিয়ে perfect number generate করা যায়
#include<stdio.h>
#include<string.h>
int main()
{
int n,i;
int p;
scanf("%d",&n);
for(i=1; i<=n; i++)
{
scanf("%d,",&p);
if( p == 2 || p == 3 || p == 5 || p == 7 || p == 13 || p == 17 || p == 19 )
printf("Yes") ;
else printf("No");
}
}
No comments:
Post a Comment