program to display factors of number

Java program to display factors of given numbers

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 + " ");
            }
        }
    }

}

Comments

Popular posts from this blog

Java Variables and Datatype

JAVA Features

Java Fundamentals