Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- char letter;
- int l, word, num, i, s;
- int factorial = 1;
- printf("Input a word in all lowercase to be checked, with no spaces: ");
- //scanf("%s", &word);
- do
- {
- letter = getchar();
- (int) letter;
- l = letter - 96;
- word = word + l;
- } while (letter != '\n');
- printf("%d", word);
- do
- {
- num = word % 10;
- for (i=num; i>0; i--)
- {
- factorial = factorial*i;
- }
- word = word/10;
- s = s + factorial;
- } while (word != 0);
- printf("\n%d", s);
- /*if(s == word)
- {
- printf("The word you have entered is a Krishnamurti number.");
- }
- else
- {
- printf("The word you have entered is not a Krishnamurti number.");
- }*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement