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" + 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 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 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