Write a programme in blueJ (java) to assign a number and print the sum of the factors of the number.
Answers
Answered by
0
public class xyz
{
public void main(int num)
{
int temp = num; (here any number you can take)
int sum = 0;
for(int i = 1 ; i <= temp ; i++)
{
if( temp % i == 0)
sum = sum + i;
}
System.out.println(sum);
}
}
Similar questions
Geography,
7 months ago
Math,
7 months ago
Political Science,
1 year ago
English,
1 year ago
History,
1 year ago