| 3 | A and P both should be integers.*/ |
| 4 | |
| 5 | int Solution::isPower(int A) /*The function that returns appropriate output*/ |
| 6 | { |
| 7 | |
| 8 | if(A==1) return 1; //condition met as mentioned in problem statement |
| 9 | |
| 10 | for(long long int i=2;i*i<=A;i++)//start from 2 ;if start by 1 ;TLE as loop continues. |
| 11 | { |
| 12 | unsigned y=2; |
| 13 | unsigned p=pow(i,y);//function pow from math library |
| 14 | while(p<=A && p>0) |
| 15 | { if(p==A) |
| 16 | |
| 17 | { return 1;} |
| 18 | y++; |
| 19 | p=pow(i,y); |
| 20 | |
| 21 | } |
| 22 | } |
| 23 | return 0; |
| 24 | } |
nothing calls this directly
no outgoing calls
no test coverage detected