Function to count the perfect powers of K in range L to R
static int countPowers ( int a , int b , int k ) { return ( int ) ( Math . Floor ( nthRoot ( b , k ) ) - Math . Ceiling ( nthRoot ( a , k ) ) + 1 ) ; }