Close
Close

when i am entering 52 value for n in the above code i am getting no output. can you please tell me why this is happening?

   Lokesh Jawale

class pf{
    public static void powf(int n,int i){
        if(i==1){
            return ;
         }
        else{
            if(n%i==0){
                if(powf1(i)==0){
                    System.out.println("The prime factor of a number is "+i);
                 }
             }
            else{
                System.out.println(i+"is not a power factor of the number");
                powf(n,i-1);
             }
         }
     }
    public static int powf1(int i){
        int a,b=0;
        for(a=2;a<=i/2;a++){
            if(i%a==0){
                b++;
             }
         }
        return b;
     }
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        System.out.println("Enter the number of which you wish to find the prime factor of");
        int n=s.nextInt();
        int i=n/2;
        powf(n,i);
     }
}

  • someone please help me with these code
    - Lokesh Jawale

Answers

Ask Yours
Post Yours
Write your answer