Computer Science, asked by rituaroraprisha, 1 year ago

Write a programme in blueJ (java) to assign a number and print the sum of the factors of the number.

Answers

Answered by rishijadwivedip912eh
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