Count Full Prime numbers in a given range | Function to check if a number is prime or not ; If a divisor of n exists ; Function to check if a number is Full Prime or not ; If n is not a prime ; Otherwise ; Extract digit ; If any digit of n is non - prime ; Function to prlet count of Full Primes in a range [ L , R ] ; Stores count of full primes ; Check if i is full prime ; Driver code ; Stores count of full primes
function isPrime ( num ) { if ( num <= 1 ) return false ; for ( let i = 2 ; i * i <= num ; i ++ ) if ( num % i == 0 ) return false ; return true ; } function isFulPrime ( n ) { if ( ! isPrime ( n ) ) return false ; else { while ( n > 0 ) { let rem = n % 10 ; if ( ! ( rem == 2 rem == 3 rem == 5 rem == 7 ) ) return false ; n = Math . floor ( n / 10 ) ; } } return true ; } function countFulPrime ( L , R ) { let cnt = 0 ; for ( let i = L ; i <= R ; i ++ ) { if ( ( i % 2 ) != 0 && isFulPrime ( i ) ) { cnt ++ ; } } return cnt ; } let L = 1 , R = 100 ; let ans = 0 ; if ( L < 3 ) ans ++ ; document . write ( ans + countFulPrime ( L , R ) ) ;