Advertisement
Saleh127

Untitled

Apr 20th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. char a[1000];
  6. int b,c,d,e,f,i,j,k,l;
  7. while(scanf("%s",a)!=EOF)
  8. {
  9. d=0;
  10. e=0;
  11. l=strlen(a);
  12. for(i=0; i<l; i++)
  13. {
  14. if(a[i]>='A'&&a[i]<='Z')
  15. {
  16. c=a[i]-'A'+27;
  17. d+=c;
  18. }
  19. else if(a[i]>='a'&&a[i]<='z')
  20. {
  21. c=a[i]-'a'+1;
  22. d+=c;
  23. }
  24. }
  25. for(j=2;j*j<=d;j++)
  26. {
  27. if(d%j==0) e=1;
  28. }
  29. if(e) printf("It is not a prime word.\n");
  30. else printf("It is a prime word.\n");
  31. }
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement