KnowledgeBoat Logo

Computer Applications

Write a program to print all the factors of 20.

Java

Java Iterative Stmts

69 Likes

Answer

public class KboatFactors
{
    public static void main(String args[]) {
        int n = 20;
        System.out.println("Factors of 20 are:");
        for (int i = 1; i <= n; i++) {
            if (n % i == 0)
                System.out.println(i);
        }
    }
}

Output

BlueJ output of Write a program to print all the factors of 20.

Answered By

33 Likes


Related Questions