program to check an Abundant number
Here in this article we will write program to check that number is abundant or not . So for this first we have to know what is abundant number.
What is an Abundant number: –
A number is said to be Abundant number if sum of it’s all divisors except it is greater than the number itself.
for Example: –
divisors of 12 are 1 , 2 , 3 , 4 , 6 . and sum of all is 16 which is greater than 12 so 12 is an abundant number .
program to check an Abundant number:-
C++ Code:-
#include<bits/stdc++.h> using namespace std; int main() { int n,sum_d=0; cout<<"Enter a number\n"; cin>>n; // finding sum of divisors for(int i=1;i<n;i++) { if(n%i==0) sum_d+=i; } // checking abundant if(sum_d>n) cout<<n<<" is an abundant number"<<endl; else cout<<n<<" is not an abundant number"<<endl; return 0; }
Output:-
Enter a number 18 18 is an abundant number
python code:-
n=int(input()) sum=0 for i in range(1,n): if n%i==0: sum=sum+i if sum>n: print(n,"is an Abundant number ") else: print(n,"is not an Abundant number ")
output:-
12 12 is an Abundant number
Also check this:-
codechef problems:-
- Primary test
- Sum or difference
- point and line
Wipro :-
- Update the booking ID | Wipro previous year question paper solution
- Pages in PDF
- Find the location id
- Find the odd digits
- Find the Product ID
Infytq :-
Key Points;-
Hackerrank:-
- Python : missing characters : hackerrank solution
- Python : string transformation | Hackerrank solution
- Active Traders certification test problem | Hackerrank Solution
- Usernames changes certification test problem | Hackerrank Solution
- string Representation of objects certification test hackerrank solution
- Average Function | hackerrank certification problem solution
C-tutorial:-
- Micros in C
- Pointer in c
- Function declaration
- Types of user define function
- return type of function
- 2D array
See more:-
- c program to convert specified days into years weeks and days
- Print Reverse Hollow Pyramid
- Update the booking ID | Wipro previous year question paper
- Pages in PDF | Wipro previous year question paper
- Sparse Matrix in data structure
- Find the location ID | Wipro previous year Coding question
- find the odd digits | Wipro Coding question
- Find the product id | Wipro Coding question
- Difference between static and dynamic memory allocation
- What is asymptotic Notation