Assume the value of a letter is its position in the alphabet: A = 1, B = 2, ... Z = 26.
Let S be the sum of the letters in word W . If S is a prime number, then W is a prime word .
For example: "PRIME" is a prime word since it has a value of 61.
How many words in this text file are prime words ? Click here to open the file.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The answer is 157 .
Iterate through the words in the file. For each word, iterate through the characters, convert them to integer values, and determine if their sum is prime. Use a variable v to keep track of how many prime words you find. Return the value of v once you reach the end of the file.