From a7d4959846a964e75470e6599f6ebba503ec6f1c Mon Sep 17 00:00:00 2001 From: Harry Date: Wed, 26 May 2021 18:33:18 +0530 Subject: [PATCH] Check if a number is perfect --- Perfectnumber.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Perfectnumber.cpp diff --git a/Perfectnumber.cpp b/Perfectnumber.cpp new file mode 100644 index 0000000..6a66fa2 --- /dev/null +++ b/Perfectnumber.cpp @@ -0,0 +1,25 @@ +// Cpp Program to check if a number is perfect number +/*a perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For instance, 6 has divisors 1, 2 and 3 (excluding itself), and 1 + 2 + 3 = 6, so 6 is a perfect number.*/ +#include +using namespace std; +int Check_perfect(int n) +{ + int i,sum=0; + for(i=1;i>n; + if(Check_perfect(n)) + cout<<"It is a perfect number"; + else + cout<<"It is not a perfect number"; +} \ No newline at end of file