Computer Science, asked by kritika2727, 1 year ago

write a program to find sum of factors of 10 using for loop in java .Please do it . urgent

Answers

Answered by Incredible29
6
Heya user ,
Here is your answer !!

public class Sum
{
public static void main ( String args [] )
int N = 10 ;
int S = 0 ;
for ( int i = 1 ; i < = 10 ; i ++ )
{
if ( N % i == 0 )
S = S + i ;
}
System.out.println ( " sum of factors : " + S ) ;
}
}


OUTPUT :
sum of factors : 18

Hope it helps you !!
Similar questions