Abundant Number
- Categories Java
Find if given number is a Abundant number or not.
Abundant number: sum of factor is greater then the number itself.
e.g. 12. Factors: 1, 2, 3, 4, 6 = 16 >12
public class AbundantNum
{
public static void main(String[] args)
{
System.out.println("Enter the number:");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0;
for(int i = 1; i < n; i++)
{
if (n % i == 0)
sum = sum + i;
}
if (sum > n)
System.out.println("Yes");
else
System.out.println("No");
}
}
You may also like
Single Linked List Programs in Java
28 August, 2021
Implementing Stack using Array in Java
28 August, 2021
Constructor Programs
3 July, 2021