#include <stdio.h>
#include <math.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
#define SIZE 40
long long int status[SIZE]={0},ar[50]={0};
long long int i,j;
void sieve()
{
int i,j;
for(i=0;i<SIZE;i++) status[i]= 0;
int sq = sqrt(SIZE);
for(i=4;i<=SIZE;i+=2) status[i] = 1;
for(i=3;i<=sq;i+=2)
{
if(status[i]==0)
{
for(j=2*i;j<=SIZE;j+=i)
status[j]=1;
}
}
status[1] = 1;
}
int main()
{
sieve();
long long n;
while(cin>>n)
{
long long k1;
if(n==0)
break;
else
{
if(status[n]==0)
{
if(n==11 || n==23 || n==29)
{
cout<<"Given number is prime. But, NO perfect number is available." << endl;
}
else
{
k1=(pow(2,(n-1))+.00000000001)*((pow(2,n)+.00000000001)-1);
printf("Perfect: %lld!\n",k1);
}
}
else
{
printf("Given number is NOT prime! NO perfect number is available.\n");
}
}
}
}
#include <math.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
#define SIZE 40
long long int status[SIZE]={0},ar[50]={0};
long long int i,j;
void sieve()
{
int i,j;
for(i=0;i<SIZE;i++) status[i]= 0;
int sq = sqrt(SIZE);
for(i=4;i<=SIZE;i+=2) status[i] = 1;
for(i=3;i<=sq;i+=2)
{
if(status[i]==0)
{
for(j=2*i;j<=SIZE;j+=i)
status[j]=1;
}
}
status[1] = 1;
}
int main()
{
sieve();
long long n;
while(cin>>n)
{
long long k1;
if(n==0)
break;
else
{
if(status[n]==0)
{
if(n==11 || n==23 || n==29)
{
cout<<"Given number is prime. But, NO perfect number is available." << endl;
}
else
{
k1=(pow(2,(n-1))+.00000000001)*((pow(2,n)+.00000000001)-1);
printf("Perfect: %lld!\n",k1);
}
}
else
{
printf("Given number is NOT prime! NO perfect number is available.\n");
}
}
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন