Write a program in java
to input a number and find the sum of its factors and print the sum.
Answers
Answered by
0
Answer:
ok bro I try to write your answer
Answered by
1
Answer
import java.util.Scanner;
public class factor
{
public static void main(String args[])
{
Scanner Sc = new Scanner (System.in);
System.out.println ("Enter the number");
int n = Sc.nextInt ();
int s = 0;
for ( int i = 1; i<= n; i++)
{
if (n%i==0)
{
System.out.println ("factor of " +n+"is");
System.out.println (i);
s = s + i;
}
}
System.out.println("sum of its factor is = " +s);
}
}
Explanation:
mark me as brainliest
Similar questions
Political Science,
1 month ago
Social Sciences,
2 months ago
Biology,
9 months ago
English,
9 months ago