write a program to find sum of factors of 10 using for loop in java .Please do it . urgent
Answers
Answered by
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 !!
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
English,
8 months ago
Biology,
8 months ago
Math,
8 months ago
Math,
1 year ago
Social Sciences,
1 year ago