---
title: "How do I write a program in C++ to find the perfect numbers between 1 and 500?"  
description: "How do I write a program in C++ to find the perfect numbers between 1 and 500?"  
author: "Mukul Goenka"  
published: 2021-11-12  
updated: 2021-11-12  
canonical: https://www.mindstick.com/forum/156828/how-do-i-write-a-program-in-c-plus-plus-to-find-the-perfect-numbers-between-1-and-500  
category: "java"  
tags: ["programming language"]  
reading_time: 1 minute  

---

# How do I write a program in C++ to find the perfect numbers between 1 and 500?

How do I write a [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) in C++ to find the perfect numbers between 1 and 500?\

## Replies

### Reply by Ravi Vishwakarma

```
#include <iostream>using namespace std;void findPerfectNumber(int start, int end);int isPerfectNumber(int num);int main(){    findPerfectNumber(1,500);    return 0;}void findPerfectNumber(int start, int end){    for(int i = start; i<= end; i++){        if(isPerfectNumber(i))            cout<< i << ', ';    }    cout<<'\b\b ';}int isPerfectNumber(int num){    int sum = 0;    for(int i =1; i<=num/2;i++)        if(num%i == 0)            sum += i;    return num == sum ? 1:0;}
```

Output.

6, 28, 496

**What is perfect no.**

> perfect number, a positive integer that is equal to the sum of its proper divisors. The smallest perfect number is 6, which is the sum of 1, 2, and 3. Other perfect numbers are 28, 496, and 8,128.


---

Original Source: https://www.mindstick.com/forum/156828/how-do-i-write-a-program-in-c-plus-plus-to-find-the-perfect-numbers-between-1-and-500

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
