Write a program in JAVA to count the number of factors of a number .( which has to be entered by the user using SCANNER class)
Auror:
can i write using
Answers
Answered by
1
package SimplerPrograms;
import java.util.Scanner;
public class FactorsOfNumberUsingFor {
private static Scanner sc;
public static void main(String[] args) {
int Number, i;
sc = new Scanner(System.in);
System.out.println("Please Enter any number to Find Factors: ");
Number = sc.nextInt();
for(i = 1; i <= Number; i++) {
if(Number%i == 0) {
System.out.format(" %d ", i);
}
}
}
}
import java.util.Scanner;
public class FactorsOfNumberUsingFor {
private static Scanner sc;
public static void main(String[] args) {
int Number, i;
sc = new Scanner(System.in);
System.out.println("Please Enter any number to Find Factors: ");
Number = sc.nextInt();
for(i = 1; i <= Number; i++) {
if(Number%i == 0) {
System.out.format(" %d ", i);
}
}
}
}
Answered by
1
Answer:
this is the answer
Explanation:
I hope it helps
Attachments:
Similar questions