#include <iostream>
#include <cstdio>
#include <string.h>
#include <math.h>
int prime (int num){
int flag=0,sq,j;
if(num==1) return 0;
else{
sq=sqrt(num);
for(j=2;j<=sq;j++){
if(num%j==0){
flag=1;
break;
}
}
}
return flag;
}
int main (){
int i,j,sum,temp;
char a[10000];
while(scanf("%s",a)!=EOF){
sum=0;temp=0;
for(i=0;a[i]!='\0';i++){
if((a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='Z')){
if((a[i]>='a'&&a[i]<='z')){
a[i]=a[i]-96;
}
if((a[i]>='A'&&a[i]<='Z')){
a[i]=a[i]-38;
}
sum+=(a[i]-0);
}
}
temp=prime(sum);
if(temp==0)
printf("It is a prime word.\n");
else
printf("It is not a prime word.\n");
}
return 0;
}
#include <cstdio>
#include <string.h>
#include <math.h>
int prime (int num){
int flag=0,sq,j;
if(num==1) return 0;
else{
sq=sqrt(num);
for(j=2;j<=sq;j++){
if(num%j==0){
flag=1;
break;
}
}
}
return flag;
}
int main (){
int i,j,sum,temp;
char a[10000];
while(scanf("%s",a)!=EOF){
sum=0;temp=0;
for(i=0;a[i]!='\0';i++){
if((a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='Z')){
if((a[i]>='a'&&a[i]<='z')){
a[i]=a[i]-96;
}
if((a[i]>='A'&&a[i]<='Z')){
a[i]=a[i]-38;
}
sum+=(a[i]-0);
}
}
temp=prime(sum);
if(temp==0)
printf("It is a prime word.\n");
else
printf("It is not a prime word.\n");
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন