write a javaprogram to print all all factors from input number
Answers
Answered by
1
Answer:public class Main {
public static void main(String[] args) {
// positive number
int number = 60;
System.out.print("Factors of " + number + " are: ");
// loop runs from 1 to 60
for (int i = 1; i <= number; ++i) {
// if number is divided by i
// i is the factor
if (number % i == 0) {
System.out.print(i + " ");
}
Explanation:
Similar questions
Math,
1 month ago
Computer Science,
1 month ago
Math,
2 months ago
Hindi,
2 months ago
Chemistry,
8 months ago