Count of square free divisors of a given number | Java program to find the square free divisors of a given number ; The function to check if a number is prime or not ; If the number is even then its not prime ; Driver code ; Stores the count of distinct prime factors ; Print the number of square - free divisors
import java . util . * ; class GFG { static boolean IsPrime ( int i ) { if ( i % 2 == 0 && i != 2 ) return false ; else { for ( int j = 3 ; j <= Math . sqrt ( i ) ; j += 2 ) { if ( i % j == 0 ) return false ; } return true ; } } public static void main ( String [ ] args ) { int c = 0 ; int N = 72 ; for ( int i = 2 ; i <= Math . sqrt ( N ) ; i ++ ) { if ( IsPrime ( i ) ) { if ( N % i == 0 ) { c ++ ; if ( IsPrime ( N / i ) && i != ( N / i ) ) c ++ ; } } } System . out . print ( Math . pow ( 2 , c ) - 1 ) ; } }