C # program to check if a number can be expressed as a ^ b .
using System ; class GFG { public static bool isPower ( int a ) { if ( a == 1 ) { return true ; } for ( int i = 2 ; i * i <= a ; i ++ ) { double val = Math . Log ( a ) / Math . Log ( i ) ; if ( ( val - ( int ) val ) < 0.00000001 ) { return true ; } } return false ; }