Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
524 B
2
Indexable
Never
public static int findMinPow(int n){
        int i=2;
        int j=0;
        while(i*i<=n || i*i-j*j!=n){
            if(i*i<=n){
                i++;
            }
            else if(i*i>n){
                j = (int) Math.sqrt(i*i-n);
                if(i*i-j*j==n){
                    return i;
                }else{
                    i++;
                    if(i*i>Math.pow(10,9)){
                        break;
                    }
                }
            }
        }
    return -1;
}