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
public class Factors {
public static void main(String[] args) {
int number = 60;
System.out.print("Factors of " + number + " are: ");
for(int i = 1; i <= number; ++i) {
if (number % i == 0) {
System.out.print(i + " ");
}
}
}
this is frm the net..and ...
public class Prime {
public static void main(String[] args) {
int num = 29;
boolean flag = false;
for(int i = 2; i <= num/2; ++i)
{
// condition for nonprime number
if(num % i == 0)
{
flag = true;
break;
}
}
if (!flag)
System.out.println(num + " is a prime number.");
else
System.out.println(num + " is not a prime number.");
}
}