Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a python file to check weather the given number is amstrong or not #1323

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

| Name | Github Link | Email ID |
| ------|----------|---------- |
| Tarun Nayaka R | <a href="https://github.com/Rtarun3606k">tarun Nayaka R</a> | <a href="r.tarunnayaka25042005@gmail.com">E-Mail</a> |
| Adarsh Addee | <a href="https://github.com/AdarshAddee">Adarsh Addee</a> | <a href="mailto:example@gmail.com">E-Mail</a> |
| Sarthak Roy | <a href="https://github.com/sarthakroy2002">Sarthak Roy</a> | <a href="mailto:sarthakroy2002@gmail.com">E-Mail</a> |
| Suraj Bhandarkar S | <a href="https://github.com/Suraj-Bhandarkar-S">Adarsh Addee</a> | <a href="mailto:suraj.bhandarkar13@gmail.com">E-Mail</a> |
Expand Down
53 changes: 53 additions & 0 deletions Python/amstrong.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Github username: Rtarun3606k
# Aim: python program to find an amstrong number
# Date: 10/7/2023




class colors:
RESET = '\033[0m'
RED = '\033[31m'
GREEN = '\033[32m'
YELLOW = '\033[33m'
BLUE = '\033[34m'
PURPLE = '\033[35m'
CYAN = '\033[36m'
WHITE = '\033[37m'


def amstrong():
try:
n = input("enter an number to fint weather its's amstrong number: ")
n_leng = len(n)
sum = 0
for i in range(0,n_leng):
n_index = n[i]
n_index=int(n_index)
cube = n_index**3
sum = sum + cube
n=int(n)
if sum == n:
print(f"the enter number is an amrgrong number: {n}")
else:
print(f"the enterd number {n} is not eaual to the sum {sum} ")
except Exception as e:
print('Try again after some time')


if __name__ == "__main__":
print( colors.RED + "what is amstrong number?" + colors.RESET)
print( colors.GREEN + "amstrong An Armstrong number (also known as a narcissistic number, plenary number, or a plus perfect number) \n is a number that is equal to the sum of its own digits, each raised to the power of the number of digits. \n In other words, for a number with n digits, if the sum of the nth powers of its digits is equal to the number itself, then it is an Armstrong number. \n For example, let's take the number 153: \n The number of digits in 153 is 3. \n The sum of the cubes of its digits is: 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153. \n Since the sum of the cubes of its digits is equal to the number itself, 153 is an Armstrong number."+ colors.RESET)

amstrong()

# amstrong An Armstrong number (also known as a narcissistic number, plenary number, or a plus perfect number) is a number that is equal to the sum of its own digits, each raised to the power of the number of digits.

# In other words, for a number with n digits, if the sum of the nth powers of its digits is equal to the number itself, then it is an Armstrong number.

# For example, let's take the number 153:

# - The number of digits in 153 is 3.
# - The sum of the cubes of its digits is: 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153.

# Since the sum of the cubes of its digits is equal to the number itself, 153 is an Armstrong number.