Posted 24 October 2010 - 08:35 PM
A prime number is an integer greater than 1 whose only integer factors are 1 and itself. A right-
truncatable prime number (or right-prime number) is a prime number that remains prime as each
of its rightmost digits is removed. For example, consider the value 719. 719 is prime, 71 is prime,
and 7 is prime. Thus, 719 is a right-prime number.
Alternatively, consider the value 97. Although 97 is prime, 9 is not. Thus, 97 is not a right-prime
Your algorithm should indicate where in your program you will use
loops, where you will use decision statements, and what computations you will make.
The input to the program is a single integer y. The input value may be any number between 2 and
-1 ( 2,147,483,647), inclusive. Given an input value y, write a program that determines if y is
The program should produce exactly one line of text as output which indicates whether y is a
right-prime. The main function should input the value from stdin and output the text to stdout.
The conversion from input to output should be performed in a different function called
isRightPrime. This function should accept an integer parameter which will be the value to test to
see if it is right-prime. In addition, this function should return an integer value that equals 1 if the
number is right-prime and 0 if it is not right-prime. This function will need the ability to determine if
successive values are prime, so it should call the isPrime function described below.
The isPrime function should accept an integer parameter, x, which will be the value to test to see
if it is prime. In addition, this function should return an integer value that equals 1 if x is prime and
0 if x is not prime to isRightPrime.