#include <stdio.h>
int main()
{ int x,flag,i;
int arr[]={561, 1105, 1729, 2465, 2821,
6601, 8911, 10585, 15841, 29341,
41041, 46657, 52633, 62745, 63973};
while(1){
flag=0;
scanf("%d",&x);
if(x==0)
break;
for(i=0;i<15;i++){
if(x==arr[i]){
flag=1;
break;
}
}
if(flag)
printf("The number %d is a Carmichael number.\n",x);
else
printf("%d is normal.\n",x);
}
return 0;
}
int main()
{ int x,flag,i;
int arr[]={561, 1105, 1729, 2465, 2821,
6601, 8911, 10585, 15841, 29341,
41041, 46657, 52633, 62745, 63973};
while(1){
flag=0;
scanf("%d",&x);
if(x==0)
break;
for(i=0;i<15;i++){
if(x==arr[i]){
flag=1;
break;
}
}
if(flag)
printf("The number %d is a Carmichael number.\n",x);
else
printf("%d is normal.\n",x);
}
return 0;
}
The problem objective is to get the numbers carmichael not enter them directly as you do.
ReplyDeleteThanks a lot for your comment :) ... Actually i got these numbers by another program I wrote ...
DeleteThis actually for the time complexity issue ... You just have only several cases .. Why don't we store only the required elements to get the best time ;) ??
From my point of view I think it's more important to solve a problem correctly. In a real programming competition I think is not allowed to use this type of "shortcuts".
DeleteThis is just my opinion ;-)
Thanks a lot for your reply :) :D I really apperciate your opinion ... I will try to find the code I generated this number with to add it ...
Delete