Russian Doll prime number Java program





Russian Doll Primes are prime numbers whose right digit can be repeatedly removed, and are still prime.



so the basic condition for a number to be a russian doll prime number is:-





  1. Number should be prime

  2. Remove right most digit and again check it is prime or not

  3. Repeat 2 until you have checked your all digits in a number.







Example:




353 — first check whether 353 is a prime number or not. condition true so now come to step 2 and remove its last digit. you have now 35 which is not a prime number- condition false.

 
so 353 is a prime number but not a russian doll prime number.

 

2. 293 - first check whether 293 is a prime number or not. condition true so now come to step 2 and remove its last digit. you have now 29 which is also a prime number- condition true. Again remove its last digit. Finally you have 2 which is also a prime number.


 
So, 293 is a russian doll prime number.


For implementation of Russian doll prime number in java, go through this video.


 


Comments