Darsh seemingly down-to-earth guy. Dash has a Brother Nathan. Nathan leads a life of a computer hacker by day and a thief by night. One day, Nathan tries to break the door digital lock of Darsh’s room.
Darsh who wants to prevent it thinks to give Passcode for security.
But it only accepts a perfect number as input. Can you help him to make a program for checking the given number is the perfect number or not…
Explanation
For example, 6 is a positive number that is completely divisible by 1, 2, and 3.
We know that the number is also divisible by itself but we will include it in the addition of divisors. When we add these divisors (1 + 2 + 3 = 6), it produces 6, which is equal to the number that we have considered. So, we can say that 6 is a perfect number.
Input:
Get a integer input “num”
Output:
The given number is a perfect number or not a perfect number.
#include <stdio.h> int perfect(int number); int main() { int a; scanf("%d",&a); if(perfect(a)==a) printf("Perfect Number"); else printf("Not a Perfect Number"); return 0; } int perfect(int numbr) { int i,sum=0; for(i=1;i<=numbr/2;i++) {if(numbr%i==0){ sum+=i;} } return sum; }
INPUT_1:
6
OUTPUT:
Perfect Number
INPUT_2:
496
OUTPUT:
Perfect Number
INPUT_3:
28
OUTPUT:
Perfect Number
INPUT_4:
10
OUTPUT:
Not a Perfect Number
INPUT_5:
30
OUTPUT:
Not a Perfect Number
ILLUSTRATION
Morae Q!
- Conversion of days into year, weeks and days.
- Find if the number is a perfect number or not.
- Compute conversion of Binary to Octal.
- Return the sum of digits in a number.
- Find if a word exists or not in a sentence.
- Convert Numbers into Words.
- Read a word if it consists only of the letters known.
- Check if the string is a dynamic string or not.
- Convert all Uppercase letters to Lowercase and vice-versa.
- Change the string such that there are no matching adjacent characters.
- Find the number of sub-strings which start and end both in 1.
- Find the start and end index of unsorted sub-array.
- Find the maximum number of pairs that can be formed.
- Figure out the number of bubbly words present.
- Check if a string is lapindrome or not even with a middle character.
- Seating layout in a triangular shaped class according to the number of rows.
- Find and Sort a sub-array which makes whole array sorted.
- Seating layout according to the number of rows.
- Find the final states of the bulbs.
- Check if reversing sub array makes the array sorted.