#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.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Output.
6, 28, 496
What is perfect no.