GENERAL DESCRIPTION

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 number. (Source: The Prime Pages, http://www.utm.edu/research/primes/).

In order to receive any credit on this program, you must provide a detailed, correct algorithm. This algorithm will be judged more critically than the previous algorithm. If you are still unsure about writing algorithms, you may use the example given on pages 73 - 75 in your textbook as a guideline. As in that example, 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 231-1 ( 2,147,483,647), inclusive. Given an input value y, write a program that determines if y is right-prime.

Your 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.

Fbody 682

VernonDozier 2,218

VernonDozier 2,218

Fbody
commented:
That knock really wasn't necessary. +4

jjspikejones
commented:
thank you +0

Fbody 682