Computer Science, asked by AvinavSingh2417, 1 year ago

write a program in java to print all factors of 20

Answers

Answered by aakarsh09
168
class factors
{
public static void main(String args[])
{
for(int a=1;a<=20;a++)
{
if(20%a==0)
System.out.println(a);
}
}




Follow me if you want more answers for java
Answered by gayatrikumari99sl
3

Answer:

This is the required program and output are 1,2, 4,5,10 and 20

Explanation:

Class factor

{

  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

Factor of 20 are :

1,2,,4,5,10,20.

#SPJ3

Similar questions