Computer Science, asked by lilsa, 6 months ago

Write a program in java to accept a number from user and print all the factors.

Please answer fast​

Answers

Answered by kellyquinn13
3
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 + " ");
}
}
}
}



Mark me as brainlest
Similar questions