#include <stdio.h>
#include <math.h>
int main( void ) {
int tests[ ] = { 1 , 5 , 10 , 25 , 100 , 125 , 250 , 625 , 1000 } ;
int num_tests = sizeof ( tests) / sizeof ( tests[ 0 ] ) ;
int i;
for ( i = 0 ; i < num_tests; ++ i)
{
int x = tests[ i] ;
int n
= ( int ) ( log ( x
) / log ( 5 ) ) ; // get n = log5(x), truncated to integer if ( pow ( 5 , n
) == x
) // test to see whether x == 5^n printf ( "%d is a power of 5\n " , x
) ; else
printf ( "%d is not a power of 5\n " , x
) ; }
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgppbnQgbWFpbih2b2lkKSB7CglpbnQgdGVzdHNbXSA9IHsgMSwgNSwgMTAsIDI1LCAxMDAsIDEyNSwgMjUwLCA2MjUsIDEwMDAgfTsKCWludCBudW1fdGVzdHMgPSBzaXplb2YodGVzdHMpIC8gc2l6ZW9mKHRlc3RzWzBdKTsKCWludCBpOwoKCWZvciAoaSA9IDA7IGkgPCBudW1fdGVzdHM7ICsraSkKCXsKCQlpbnQgeCA9IHRlc3RzW2ldOwoJCWludCBuID0gKGludCkobG9nKHgpIC8gbG9nKDUpKTsgLy8gZ2V0IG4gPSBsb2c1KHgpLCB0cnVuY2F0ZWQgdG8gaW50ZWdlcgogICAgICAgIGlmIChwb3coNSwgbikgPT0geCkgICAgICAgICAvLyB0ZXN0IHRvIHNlZSB3aGV0aGVyIHggPT0gNV5uCiAgICAgICAgICAgIHByaW50ZigiJWQgaXMgYSBwb3dlciBvZiA1XG4iLCB4KTsKICAgICAgICBlbHNlCiAgICAgICAgICAgIHByaW50ZigiJWQgaXMgbm90IGEgcG93ZXIgb2YgNVxuIiwgeCk7Cgl9CglyZXR1cm4gMDsKfQo=