Number of distinct integers obtained by lcm ( X , N ) / X | C ++ program to find distinct integers ontained by lcm ( x , num ) / x ; Function to count the number of distinct integers ontained by lcm ( x , num ) / x ; iterate to count the number of factors ; Driver Code
#include <cmath> NEW_LINE #include <iostream> NEW_LINE using namespace std ; int numberOfDistinct ( int n ) { int ans = 0 ; for ( int i = 1 ; i <= sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { ans ++ ; if ( ( n / i ) != i ) ans ++ ; } } return ans ; } int main ( ) { int n = 3 ; cout << numberOfDistinct ( n ) ; return 0 ; }