Computer Applications
Write a program to print all the factors of 20.
Java
Java Iterative Stmts
70 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. BlueJ output of Write a program to print all the factors of 20.](https://cdn1.knowledgeboat.com/img/lgx8/c6-decision-control-p2.jpg)
Answered By
33 Likes
Related Questions
Give one difference between while and do while loop.
Write a program in Java using for loop to print all the odd and even number upto 30 terms.
Write a program using while loop to generate the first 10 natural numbers and their sum.
Program to check whether the product of two numbers is a buzz number or not.
[A number that ends with 7 or is divisible by 7, is called a buzz number]