By SHAHINA S
Program to check whether the numbers are Abundant,Automorphic,Friendly pair,Harshad number and Strong Number using C++
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.
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
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)
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
For example
* 145
* sum of factorial of digits=1!+4!+5!=145
Submitted by SHAHINA S (Shahina123)
Download packets of source code on Coders Packet
Comments