We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #193: Squarefree Numbers
  4. Discussions

Project Euler #193: Squarefree Numbers

Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • tanushree_yadav
    5 years ago+ 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

    -1|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy