Perfect primes P90664


Statement
 

pdf   zip

html

Given a natural number n, let s(n) be the sum of the digits (in base 10) of n. We say that n is a perfect prime if the infinite sequence formed by n, s(n), s(s(n)), … only contains prime numbers. For instance, 977 is a perfect prime, because 977, as well as 9+7+7=23, 2+3=5, 5, 5, … are prime numbers.

Input

Each line of the input contains a number 1≤ n ≤ 4000000. A line with n=0 marks the end of the input.

Output

For each n, print in a line “yes” or “no”, depending on whether n is a perfect prime or it is not.

Public test cases
  • Input

    977
    1
    7
    17
    0
    

    Output

    yes
    no
    yes
    no
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan Spanish
    Official solutions
    C++ Java Python
    User solutions
    C C++