Q:

Program to print all abundant numbers between 1 and 100

belongs to collection: Number Programs

0

The abundant number can be called an excessive number and defined as the number for which the sum of its proper divisors is greater than the number itself.

A first abundant number is the integer 12 having the sum (16) of its proper divisors (1,2,3,4,6) which is greater than itself(12).

Examples: 12, 18, 20, 24, 30, 36

In this program, we have to find all abundant numbers between 1 and 100.

Algorithm

  • STEP 1: START
  • STEP 2: DEFINE n, i, j
  • STEP 3: SET sum =0
  • STEP 4: SET n =100
  • STEP 5: REPEAT STEP 6 to STEP 10 UNTIL i<=n
  • STEP 6: REPEAT STEP 7 and STEP 8 UNTIL j<=i/2
  • STEP 7: if i%j ==0
  • STEP 8: sum =sum + j
  • STEP 9: if sum>i then PRINT i+
  • STEP 10: SET sum=0
  • STEP 11: END

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Java Program

public class Abundant_number_1to100 {  
    public static void main(String[] args) {  
         int n, i, j, sum = 0;  
n =100;  
for (i = 1; i <= n; i++)  
{  
           for (j = 1; j <= i/2; j++)   
           {  
                     if (i % j == 0)  
                     {  
                                sum = sum + j;  
                     }  
           }  
                if (sum > i)  
                        System.out.print( i+" ");  
                sum = 0;  
}  
}     
}  

 

Output:

12 18 20 24 30 36 40 42 48 54 56 60 66 70 72 78 80 84 88 90 96 100 

 

C Program

#include <stdio.h>  
  int main () {  
        int n, i, j, sum = 0;  
        n=100;  
        for (i = 1; i <= n; i++) {  
                for (j = 1; j <= i/2; j++) {  
                        if (i % j == 0) {  
                                sum = sum + j;  
                        }  
                }  
  
                if (sum > i)  
                        printf("%d ", i);  
                sum = 0;  
        }  
        printf("\n");  
        return 0;  
  } 

 

Output:

12 18 20 24 30 36 40 42 48 54 56 60 66 70 72 78 80 84 88 90 96 100

 

Python Program

n = 101  
su = 0  
for i in range(1, n):  
    for j in range(1, int(i)):  
        if (i % j == 0):  
            su = su + j  
    if (su > i):  
        print( i)  
    su = 0  

Output:

12 18 20 24 30 36 40 42 48 54 56 60 66 70 72 78 80 84 88 90 96 100 

 

PHP Program

<?php   
$n = 100;  
$su = 0;  
for($i = 1;$i<=$n;$i++)  
{  
  for($j=1; $j<=$i/2;$j++)  
    {  
      if ($i % $j == 0){  
            $su = $su + $j;  
            }  
    }  
  if ($su > $i)  
    {  
        echo $i,"  ";  
    }  
    $su = 0;  
}  
?>  

 

Output:

12 18 20 24 30 36 40 42 48 54 56 60 66 70 72 78 80 84 88 90 96 100

 

C# program

using System;   
public class Abundant {   
    public static void Main()   
    {   
int n = 100, i ,j;  
int su = 0;  
for(i = 1;i<=n;i++)  
{  
  for(j=1; j<=i/2;j++)  
    {  
      if (i % j == 0){  
            su = su + j;  
            }  
    }  
  if (su > i)  
    {  
        Console.Write(i+" ");  
    }  
    su = 0;  
    }  
}  
} 

 

Output:

12 18 20 24 30 36 40 42 48 54 56 60 66 70 72 78 80 84 88 90 96 100

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Program to print all Kaprekar numbers between 1 to... >>
<< Program to determine whether a given number is a t...