# FLOWCHART AND ALGORITHM FOR PERFECT NUMBERS

### WHAT ARE PERFECT NUMBERS?

According to the number theory, perfect numbers are the numbers that are equal to the sum of it's divisors excluding the number itself.

For example 6 is a perfect number. The divisors of six are 1,2,3 and 6. So, 1+2+3=6.

For example 6 is a perfect number. The divisors of six are 1,2,3 and 6. So, 1+2+3=6.

Illustration of perfect numbers |

The sum of the number excluding itself is called

**aliquot sum**. The numbers which are equal to their aliquot sum are

**perfect numbers**. Also, if we add the number itself in the sum of divisors, the for the perfect numbers the sum become double that numbers.

1+2+3+4+5+6=12=6X2.

*FOR LOOP IN C*

Since we are going to use for loop in this program, itis necessary for you to know about for loop in C.*FOR LOOP IN C*

Syntax:

```
for (initialization; condition; operation)
```

{

statements;

}

**FLOWCHART FOR FOR LOOP**

**ALGORITHM FOR PERFECT NUMBERS**

###
Step 1: Start
Step 2: For each numbers find the sum of the factorials excluding the number itself one by one.
Step 3: Display the number if its is equal to its aliquot sum.
Step 4: Stop

**FLOWCHART FOR PERFECT NUMBERS**

##
**SOURCE CODE FOR PERFECT NUMBERS IN C**

*#To display perfect numbers between 1 and 100.*```
#include<stdio.h>
#include<conio.h>
main()
{
int i,n,s;
for (n=1;n<=500;n++){
s=0;
for(i=1;i<n;i++)
{
if (n%i==0)
s=s+i;
}
if (n==s)
printf("%d\n",n);
}
getch();
}
```

*OUTPUT*

*6*

*28*

*496*

**#TO check if given number is perfect or not.**

```
#include<stdio.h>
#include<conio.h>
main()
{
int i,n,s=0;
printf("Enter a number");
scanf("%d",&n);
for(i=1;i<n;i++)
{
if (n%i==0)
s=s+i;
}
if (n==s)
printf("%d is perfect number",n);
else
printf("%d isn's perfect number");
getch();
}
```

COMMENT DOWN YOUR DOUBTS

## 3 Comments

your article on blockchain is very interesting thank you so much.

ReplyDeleteblockchain training in hyderabad

blockchain course in hyderabad

blockchain coaching in hyderabad

blockchain training institute in hyderabad

blockchain institute in hyderabad

nice information on blockchain has given thank you very much.

ReplyDeleteblockchain training in hyderabad

blockchain course in hyderabad

blockchain coaching in hyderabad

blockchain training institute in hyderabad

blockchain institute in hyderabad

Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website

ReplyDeleteblockchain online training

best blockchain online training

top blockchain online training