From 93f32afc22f524c6ac2469238ebe9261ec6eb444 Mon Sep 17 00:00:00 2001 From: anjali142 Date: Fri, 25 Oct 2019 16:26:35 +0530 Subject: [PATCH 1/4] perfect --- perfect.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 perfect.py diff --git a/perfect.py b/perfect.py new file mode 100644 index 0000000..1fd22ca --- /dev/null +++ b/perfect.py @@ -0,0 +1,11 @@ +# Python Program to find Perfect Number using For loop + +Number = int(input(" Please Enter any Number: ")) +Sum = 0 +for i in range(1, Number): + if(Number % i == 0): + Sum = Sum + i +if (Sum == Number): + print(" %d is a Perfect Number" %Number) +else: + print(" %d is not a Perfect Number" %Number) \ No newline at end of file From 5634756059ce1614bf5e69faf7dc56b3f5069273 Mon Sep 17 00:00:00 2001 From: anjali142 Date: Fri, 25 Oct 2019 16:32:09 +0530 Subject: [PATCH 2/4] special_number --- special_twodigit.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 special_twodigit.py diff --git a/special_twodigit.py b/special_twodigit.py new file mode 100644 index 0000000..7616181 --- /dev/null +++ b/special_twodigit.py @@ -0,0 +1,22 @@ +def specialNumber(n): + + # Checking whether entered + # number is 2 digit or not + if (n < 10 or n > 99): + print("Invalid Input! Number", + " should have 2 digits only") + else: + first = n // 10 + last = n % 10 + sum = first + last + pro = first * last + if ((sum + pro) == n): + print(n ," is a Special ", + "Two-Digit Number") + else: + print(n , " is Not a ", + "Special Two-Digit Number") + +# Driver code +n = 59 +specialNumber(n) \ No newline at end of file From 5d6410e36f241137775d86cda749c2391bbd7188 Mon Sep 17 00:00:00 2001 From: anjali142 Date: Fri, 25 Oct 2019 16:38:19 +0530 Subject: [PATCH 3/4] strong_number --- strong.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 strong.py diff --git a/strong.py b/strong.py new file mode 100644 index 0000000..a13a778 --- /dev/null +++ b/strong.py @@ -0,0 +1,16 @@ +sum1=0 +num=int(input("Enter a number:")) +temp=num +while(num): + i=1 + f=1 + r=num%10 + while(i<=r): + f=f*i + i=i+1 + sum1=sum1+f + num=num//10 +if(sum1==temp): + print("The number is a strong number") +else: + print("The number is not a strong number") \ No newline at end of file From 2cea09faf7065707122f28a7b8138aa909fad9db Mon Sep 17 00:00:00 2001 From: Anjali Deep <45489595+anjali142@users.noreply.github.com> Date: Mon, 28 Oct 2019 10:16:12 +0530 Subject: [PATCH 4/4] Krishnamurthy number A Krishnamurthy number is a number whose sum of the factorial of digits is equal to the number itself. For example 145, sum of factorial of each digits: 1! + 4! + 5! = 1 + 24 + 120 = 145 --- krishnamurthy.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 krishnamurthy.py diff --git a/krishnamurthy.py b/krishnamurthy.py new file mode 100644 index 0000000..f52c47e --- /dev/null +++ b/krishnamurthy.py @@ -0,0 +1,24 @@ +def factorial(n) : + fact = 1; + while (n != 0) : + fact = fact * n; + n = n - 1 + return fact + +def isKrishnamurthy(n) : + sum = 0 + temp = n + while (temp != 0) : + + sum = sum + factorial( temp % 10) + + temp = temp / 10; + + return (sum == n) + +n = 145 +if (isKrishnamurthy(n)) : + print "YES" +else : + print "NO" +