From 2b852e3139a8886faf5518588c1ccadb408dac0e Mon Sep 17 00:00:00 2001 From: tarunnayakar Date: Sat, 7 Oct 2023 14:33:36 +0530 Subject: [PATCH 1/2] added a python file to check weather the given number is amstrong or not --- CONTRIBUTORS.md | 1 + Python/amstrong.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Python/amstrong.py diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f3226313..fe025da0 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -12,6 +12,7 @@ | Name | Github Link | Email ID | | ------|----------|---------- | +| Tarun Nayaka R | Adarsh Addee | E-Mail | | Adarsh Addee | Adarsh Addee | E-Mail | | Sarthak Roy | Sarthak Roy | E-Mail | | Suraj Bhandarkar S | Adarsh Addee | E-Mail | diff --git a/Python/amstrong.py b/Python/amstrong.py new file mode 100644 index 00000000..200289f1 --- /dev/null +++ b/Python/amstrong.py @@ -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. \ No newline at end of file From 1c994393a7696bf645a8318e2e7e7ce6611e4cf1 Mon Sep 17 00:00:00 2001 From: tarunnayakar Date: Sat, 7 Oct 2023 14:34:48 +0530 Subject: [PATCH 2/2] added a python file to check weather the given number is amstrong or not --- CONTRIBUTORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index fe025da0..3c5fe005 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -12,7 +12,7 @@ | Name | Github Link | Email ID | | ------|----------|---------- | -| Tarun Nayaka R | Adarsh Addee | E-Mail | +| Tarun Nayaka R | tarun Nayaka R | E-Mail | | Adarsh Addee | Adarsh Addee | E-Mail | | Sarthak Roy | Sarthak Roy | E-Mail | | Suraj Bhandarkar S | Adarsh Addee | E-Mail |