Pandigital Product | C ++ code to check the number is Pandigital Product or not ; To check the string formed from multiplicand , multiplier and product is pandigital ; calculate the multiplicand , multiplier , and product eligible for pandigital ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isPandigital ( string str ) { if ( str . length ( ) != 9 ) return false ; char ch [ str . length ( ) ] ; strcpy ( ch , str . c_str ( ) ) ; sort ( ch , ch + str . length ( ) ) ; string s = ch ; if ( s . compare ( "123456789" ) == 0 ) return true ; else return true ; } bool PandigitalProduct_1_9 ( int n ) { for ( int i = 1 ; i * i <= n ; i ++ ) if ( n % i == 0 && isPandigital ( to_string ( n ) + to_string ( i ) + to_string ( n / i ) ) ) return true ; return false ; } int main ( ) { int n = 6952 ; if ( PandigitalProduct_1_9 ( n ) == true ) cout << " yes " ; else cout << " no " ; return 0 ; }