Abundant Number

Abundant Number


A number that is smaller than the sum of its aliquot parts (proper divisors) is known as an Abundant Number. Twelve is the smallest abundant number - the sum of its aliquot parts is 1 + 2 + 3 + 4 + 6 = 16 - followed by 18, 20, 24, and 30.
 /*
 * WAP to print all the abudant numbers between m and n. 
 * A weird number is one which is smaller than the sum of its aliquot parts.
 */
import java.util.*;
class AbundantNo
{
public static void main (String args[])throws InputMismatchException
{
Scanner scan = new Scanner(System.in);
int m,n,i,j,s;

System.out.println("Enter the limits m and n: ");
    m = scan.nextInt();
    n = scan.nextInt();

    for(j=m;j<=n;j++){
        s=0;
        for(i=1;i< j;i++){
            if(j%i == 0)
                s=s+i;
        }
        if(s>j)
        System.out.print(j+" ");
    }

}//end of main
}//end of class

Have something to say? Log in to comment on this post.

0 comments