From 9faf04ec398db44ad3c7d87bf2adc1f7149f0591 Mon Sep 17 00:00:00 2001 From: SufyanKhan0 <67229679+SufyanKhan0@users.noreply.github.com> Date: Thu, 2 Sep 2021 23:56:50 +0530 Subject: [PATCH 1/2] On branch master Your branch is up to date with 'origin/master'. Changes to be committed: new file: Python/AbundantNumber.py --- Python/AbundantNumber.py | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Python/AbundantNumber.py diff --git a/Python/AbundantNumber.py b/Python/AbundantNumber.py new file mode 100644 index 00000000..c7eab04a --- /dev/null +++ b/Python/AbundantNumber.py @@ -0,0 +1,50 @@ +#Python program to check if a number is Abundant or not + +def is_abundant(n): + s=0 + for i in range(1,n): # This for loop calculates the sum of the divisors of a number + if n%i==0: + s = s + i + + a = s-n #Calculates the difference between the sum of the divisors and the given number + + if s > n: + print(n,"is an Abundant Number and the Abundance is",a) + else : + print(n,"is not an Abundant Number") + +#User Input: +print("Enter the number to check:") +n = int(input()) + +is_abundant(n) + + +''' +Explanation: +A number is said to be abundant if the sum of the divisors of the +number is greater than the number itself. And the differnce between these two +values is called the abundance of an abundant number. + +Examples of Abundant Numbers: +->12: + Divisors of 12: 1,2,3,4,6 + Sum of divisors: 16 + Abundance: 16-12 = 4 + + ->18: + divisors of 18: 1,2,3,6,9 + Sum of divisors: 21 + Abundance: 21-18 = 3 + +Sample Input: +Enter the Number to check: +12 + +Sample Output: +12 is an Abundant Number and the Abundance is 4 + +Time Complexity : O(n) +Space Complexity : O(1) + +''' From 6c581c8ee7d3692b6cf8e03c51128911eb7d79ba Mon Sep 17 00:00:00 2001 From: SufyanKhan0 <67229679+SufyanKhan0@users.noreply.github.com> Date: Thu, 2 Sep 2021 23:58:55 +0530 Subject: [PATCH 2/2] On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) Changes to be committed: modified: Python/README.md --- Python/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/README.md b/Python/README.md index dbeccb06..dec5fc18 100644 --- a/Python/README.md +++ b/Python/README.md @@ -4,6 +4,8 @@ Format: -[Program name](name of the file) -[0/1 Knapsack Problem using Dynamic Programming approach](Knapsack_DP.py) +-[Abundant Number](AbundantNumber.py) + -[Anagrams](anagrams.py) -[Arithmetic Progression](arithmetic.py)