Answers for "how to write a programme to display all the factors of a number in java"

1

how to write a programme to display all the factors of a number in java

public class Factors {

    public static void main(String[] args) {

        int number = 60;

        System.out.print("Factors of " + number + " are: ");
        for(int i = 1; i <= number; ++i) {
            if (number % i == 0) {
                System.out.print(i + " ");
            }
        }
    }
}
Posted by: Guest on August-19-2020

Code answers related to "how to write a programme to display all the factors of a number in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language