Computer Applications

Give output of the following method definition and also write the mathematical operation they carry out:


void test1(int n)
{
for(int x=1; x<=< span>n; x++)
if(n%x == 0)
    System. out.println(x);
}

if 12 is passed to n.

Java

User Defined Methods

163 Likes

Answer

1
2
3
4
6
12

Working

This method finds the factors of n.

Answered By

75 Likes


Related Questions