Prime Word
InterviewTime limit2sMemory limit128 MB
Sum letter values (a-z=1-26, A-Z=27-52) for a word and print whether the sum is prime (with 1 counted as prime).
- Level
Easy2 of 10
- Topics
- String, Math, Implementation
- Solved
- No attempts yet
Problem
A prime number is a number divisible only by 1 and itself. In this problem, 1 is also treated as prime.
You are given one English word consisting only of uppercase and lowercase letters. Convert each character to a number using the following rules, then add all values.
athroughzhave values 1 through 26.AthroughZhave values 27 through 52.
For example, the sum for cyworld is 100, and the sum for abcd is 10.
A word is called a prime word if the sum of its character values is prime. Write a program that determines whether the given word is a prime word.
Input
The first line contains a word. Its length is at most 20, and it consists only of lowercase and uppercase English letters.
Output
If the word is a prime word, print It is a prime word. Otherwise, print It is not a prime word.