Write a java program to take input any integer number. Find the sum of all factors which is not divisible by 7. Also check out the sum of all factors of the input number is an Aramstrong number or not.
Answers
Answered by
0
import java.util.*;
import java.lang.Math;
void main()
{
public static void main(String args[])
{
int s1=0;s2=0;result=0,copy,remainder;
System.out.println("enter the number");
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(int i=1;i<=n;i++)
{
if((n%i)==0)
{
if((i%7)!=0)
{
s1=s1+i;
}
s2=s2+i;
}
}
System.out.println(s1);
copy=s2;
while (s2 != 0)
{
remainder = s2 % 10;
result=result + Math.pow(remainder, 3);
s2 /= 10;
}
if(result==copy)
{
System.out.println("Sum of all factors is Armstrong");
}
else
{
System.out.println("Sum of all factors is not Armstrong");
}
}
}
Similar questions