Check if a given number is Pronic | C / C ++ program to check if a number is pronic ; function to check Pronic Number ; Checking Pronic Number by multiplying consecutive numbers ; Driver Code ; Printing Pronic Numbers upto 200
#include <iostream> NEW_LINE #include <math.h> NEW_LINE using namespace std ; bool checkPronic ( int x ) { for ( int i = 0 ; i <= ( int ) ( sqrt ( x ) ) ; i ++ ) if ( x == i * ( i + 1 ) ) return true ; return false ; } int main ( void ) { for ( int i = 0 ; i <= 200 ; i ++ ) if ( checkPronic ( i ) ) cout << i << " ▁ " ; return 0 ; }