Give output of the following function definitions and also write what
mathematical operations they carry out
1. void test1(int n)
for(int x=1; x<=n; x++)
if(n%x == 0)
System.out.println(x):
if 12 is passed to n.
Answers
Answered by
3
Answer:
output:
1
2
3
4
6
12
Explanation:
it basically prints factor of a given no.
12%1==0 true
12%2==0 true
12%3==0 true
12%4==0 true
12%5==0 false
12%6==0 true
12%7==0 false
and so on.....
Similar questions