Coders Packet

Abundant , Automorphic , Friendly pair, Harshad and Strong number using C++

By SHAHINA S

Program to check whether the numbers are Abundant,Automorphic,Friendly pair,Harshad number and Strong Number using C++

ABUNDANT NUMBER

The User should enter a number to check whether the number is abundant or not. Then find and add the proper divisors of the number and store it in a variable "sum". Compare the user-entered value and the number stored in "sum".If the value in sum is greater than the user-entered value then the user-entered value is abundant.

For example:

* consider a number 18

* Divisors of 18 are 1,2,3,6 and 9

* sum=1+2+3+6+9=21

* 21>18 so the number is abundant.

AUTOMORPHIC NUMBER

An Automorphic number is a number whose square ends with the digit that is equal to the last digit of the given number. User has to enter a number then find its square. Compare the last digit of the square with the last digit of the number. If they are equal, then the number is automorphic.

For example:

 number    square

      5            25 

      6            36

      25          625

FRIENDLY PAIR

Amicable numbers or friendly pairs are two different numbers whose sum of divisors is equal to the other number.

For example

* considers numbers 220 and 284

* sum of proper divisors of 220=284 (divisors of 220-1,2,4,5,10,11,20,22,44,55 and 110)

* sum of proper divisors of 284=220 (divisors of 284-1,2,4,71 and 142)

In the above example, find the proper divisors of the numbers 220 and 284. sum of proper divisors of the number 220 is equal to 284 and sum of proper divisors of 284 is equal to 220.so 220 and 284 are friendly pairs.

HARSHAD NUMBER

A Harshad number is a number that is divisible by the sum of the digits of the number. Find the sum of digits of the number that is entered by the user and check whether the number is divisible by its sum of digits. If they are divisible, then we can say that the given number is Harshad number.

For example

*21

* sum of digits=2+1=3

* 21 is divisible by 3.so number is Harshad number

STRONG NUMBER

Strong number is a number whose sum of the factorial of individual digits of the number is equal to the number itself.

For example

* 145

* sum of factorial of digits=1!+4!+5!=145

 

Download project

Reviews Report

Submitted by SHAHINA S (Shahina123)

Download packets of source code on Coders Packet