Computer Science, asked by Anonymous, 1 year ago

Write a java program to input a no and print the factors of that no.Please anyone solve it by iteration method...

Answers

Answered by ferisha1809
1

import java.util.*;

class factors

{

public static void main()

{

Scanner in=new Scanner(System.in);

int n,i;

System.out.println("Enter a number");

n=in.nextInt();

for(i=1;i<=n;i++)

{

if(n%i==0)

System.out.println(i);

}

}

}

Hope it helps friend!!




ferisha1809: welcome
Similar questions