From f4a504f3c6a4c42113ee87fb5bae8091ce1b03da Mon Sep 17 00:00:00 2001 From: Udhay <72250606+Udhay-Brahmi@users.noreply.github.com> Date: Wed, 23 Dec 2020 08:00:38 +0530 Subject: [PATCH] Create Deficient Number --- Deficient Number | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Deficient Number diff --git a/Deficient Number b/Deficient Number new file mode 100644 index 0000000..b675c32 --- /dev/null +++ b/Deficient Number @@ -0,0 +1,35 @@ +// { Driver Code Starts +// Initial Template for C++ +#include +using namespace std; + + // } Driver Code Ends + + +// User function Template for C++ +class Solution { + public: + string isDeficient(long long int x) { + // code here + int sum=0; + for(int i=1;i<=sqrt(x);i++){ + if(x%i==0){sum+=i;sum+=(x/i);} + } + if(sum<(2*x)){return "YES";} + return "NO"; + } +}; + +// { Driver Code Starts. +int main() { + int t; + cin >> t; + while (t--) { + long long int x; + cin >> x; + Solution ob; + cout << ob.isDeficient(x) << endl; + } + return 0; +} + // } Driver Code Ends