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
Answered By
33 Likes
Related Questions
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]Generate the following series upto 10 terms:
1, 8, 27, 64, 125 ……..
Write a program using while loop to generate the first 10 natural numbers and their sum.
Write a program in Java using for loop to print all the odd and even number upto 30 terms.