Project Euler #193: Squarefree Numbers

  • + 1 comment

    package practiceQuestion; import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;

    public class Trys {

    public static void main(String[] args) {
        Scanner kb= new Scanner(System.in);
          int N=kb.nextInt();
        int c=0;int p=0;
          int k=kb.nextInt();
      // int m=(int) Math.pow(2, k);
         //   System.out.println(m);
        for(int i=2;i<=N;i++)
        {
            int m=(int) Math.pow(i, k);
           c=0;
            for(int j=2;j<=N;j++)
            {
                if(j%m==0){
                    p++;
                    // System.out.println(p+".... "+j);
                }
                else
                {   c++;
             //   System.out.println(c+" ");
                }
            }
        }
        p=N-p;
        System.out.println(p);
    }
    

    } // can anyone tell me why timeout is giving plz solve this