Hướng dẫn what is armstrong number in python - số armstrong trong python là gì

Trong ví dụ này, bạn sẽ học cách kiểm tra xem một số nguyên chữ N có phải là số Armstrong hay không.

Để hiểu ví dụ này, bạn nên có kiến ​​thức về các chủ đề lập trình Python sau:

  • Python nếu ... tuyên bố khác
  • Python trong khi vòng lặp

Một số nguyên dương được gọi là số lượng đơn đặt hàng n nếu

abcd... = an + bn + cn + dn + ...

Trong trường hợp số lượng 3 chữ số của Armstrong, tổng khối của mỗi chữ số bằng chính với số lượng. Ví dụ:

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.

Mã nguồn: Kiểm tra số Armstrong [cho 3 chữ số]

# Python program to check if the number is an Armstrong number or not

# take input from the user
num = int[input["Enter a number: "]]

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** 3
   temp //= 10

# display the result
if num == sum:
   print[num,"is an Armstrong number"]
else:
   print[num,"is not an Armstrong number"]

Đầu ra 1

Enter a number: 663
663 is not an Armstrong number

Đầu ra 2

Enter a number: 407
407 is an Armstrong number

Ở đây, chúng tôi yêu cầu người dùng cho một số và kiểm tra xem đó có phải là số Armstrong không.

Chúng ta cần tính toán tổng của khối lập phương của mỗi chữ số. Vì vậy, chúng tôi khởi tạo tổng thành 0 và lấy từng số chữ số bằng cách sử dụng toán tử mô đun %. Phần còn lại của một số khi nó được chia cho 10 là chữ số cuối cùng của số đó. Chúng tôi lấy các khối bằng cách sử dụng toán tử số mũ.

Cuối cùng, chúng tôi so sánh tổng với số gốc và kết luận rằng đó là số Armstrong nếu chúng bằng nhau.

Mã nguồn: Kiểm tra số lượng n chữ số của Armstrong

num = 1634

# Changed num variable to string, 
# and calculated the length [number of digits]
order = len[str[num]]

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** order
   temp //= 10

# display the result
if num == sum:
   print[num,"is an Armstrong number"]
else:
   print[num,"is not an Armstrong number"]

Bạn có thể thay đổi giá trị của num trong mã nguồn và chạy lại để kiểm tra nó.

Cải thiện bài viết

Lưu bài viết

Cho một số X, xác định xem số đã cho có phải là số Armstrong hay không. Một số nguyên dương của n chữ số được gọi là số lượng đơn đặt hàng n [thứ tự là số chữ số] nếu.n digits is called an Armstrong number of order n [order is number of digits] if.

abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 

Example:

Input : 153
Output : Yes
153 is an Armstrong number.
1*1*1 + 5*5*5 + 3*3*3 = 153

Input : 120
Output : No
120 is not a Armstrong number.
1*1*1 + 2*2*2 + 0*0*0 = 9

Input : 1253
Output : No
1253 is not a Armstrong Number
1*1*1*1 + 2*2*2*2 + 5*5*5*5 + 3*3*3*3 = 723

Input : 1634
Output : Yes
1*1*1*1 + 6*6*6*6 + 3*3*3*3 + 4*4*4*4 = 1634

Python

def

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
0

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
2
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
3
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
6
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
7

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
8
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
9
# Python program to check if the number is an Armstrong number or not

# take input from the user
num = int[input["Enter a number: "]]

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** 3
   temp //= 10

# display the result
if num == sum:
   print[num,"is an Armstrong number"]
else:
   print[num,"is not an Armstrong number"]
0

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
2
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
3
# Python program to check if the number is an Armstrong number or not

# take input from the user
num = int[input["Enter a number: "]]

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** 3
   temp //= 10

# display the result
if num == sum:
   print[num,"is an Armstrong number"]
else:
   print[num,"is not an Armstrong number"]
4
# Python program to check if the number is an Armstrong number or not

# take input from the user
num = int[input["Enter a number: "]]

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** 3
   temp //= 10

# display the result
if num == sum:
   print[num,"is an Armstrong number"]
else:
   print[num,"is not an Armstrong number"]
5
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
6
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
7

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
8
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
9
Enter a number: 663
663 is not an Armstrong number
2
Enter a number: 663
663 is not an Armstrong number
3
Enter a number: 663
663 is not an Armstrong number
3
# Python program to check if the number is an Armstrong number or not

# take input from the user
num = int[input["Enter a number: "]]

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** 3
   temp //= 10

# display the result
if num == sum:
   print[num,"is an Armstrong number"]
else:
   print[num,"is not an Armstrong number"]
5
Enter a number: 663
663 is not an Armstrong number
6__

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
9
Enter a number: 407
407 is an Armstrong number
5
Enter a number: 663
663 is not an Armstrong number
7
Enter a number: 663
663 is not an Armstrong number
2
Enter a number: 663
663 is not an Armstrong number
3__

def

num = 1634

# Changed num variable to string, 
# and calculated the length [number of digits]
order = len[str[num]]

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** order
   temp //= 10

# display the result
if num == sum:
   print[num,"is an Armstrong number"]
else:
   print[num,"is not an Armstrong number"]
9

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
6

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
5
abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
6
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
6
abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
9

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
8
abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
1
Input : 153
Output : Yes
153 is an Armstrong number.
1*1*1 + 5*5*5 + 3*3*3 = 153

Input : 120
Output : No
120 is not a Armstrong number.
1*1*1 + 2*2*2 + 0*0*0 = 9

Input : 1253
Output : No
1253 is not a Armstrong Number
1*1*1*1 + 2*2*2*2 + 5*5*5*5 + 3*3*3*3 = 723

Input : 1634
Output : Yes
1*1*1*1 + 6*6*6*6 + 3*3*3*3 + 4*4*4*4 = 1634
4
# Python program to check if the number is an Armstrong number or not

# take input from the user
num = int[input["Enter a number: "]]

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** 3
   temp //= 10

# display the result
if num == sum:
   print[num,"is an Armstrong number"]
else:
   print[num,"is not an Armstrong number"]
0

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
8
Enter a number: 407
407 is an Armstrong number
5
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
Enter a number: 407
407 is an Armstrong number
5
Enter a number: 663
663 is not an Armstrong number
3
Enter a number: 663
663 is not an Armstrong number
3
The given number 153 is armstrong number
2

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
9
The given number 153 is armstrong number
5

def

The given number 153 is armstrong number
7

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4 def1

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1def3
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4 def5

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1def7
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
6

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
5
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
02
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
6
abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
9

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
8
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
07
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4 def3
# Python program to check if the number is an Armstrong number or not

# take input from the user
num = int[input["Enter a number: "]]

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** 3
   temp //= 10

# display the result
if num == sum:
   print[num,"is an Armstrong number"]
else:
   print[num,"is not an Armstrong number"]
4
The given number 153 is armstrong number
2

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
8def7
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4 def7
Input : 153
Output : Yes
153 is an Armstrong number.
1*1*1 + 5*5*5 + 3*3*3 = 153

Input : 120
Output : No
120 is not a Armstrong number.
1*1*1 + 2*2*2 + 0*0*0 = 9

Input : 1253
Output : No
1253 is not a Armstrong Number
1*1*1*1 + 2*2*2*2 + 5*5*5*5 + 3*3*3*3 = 723

Input : 1634
Output : Yes
1*1*1*1 + 6*6*6*6 + 3*3*3*3 + 4*4*4*4 = 1634
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
17

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
8def3
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4 def3
Enter a number: 663
663 is not an Armstrong number
3
Enter a number: 663
663 is not an Armstrong number
3
The given number 153 is armstrong number
2

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
9
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
27
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
30

Enter a number: 407
407 is an Armstrong number
5
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
33

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
34
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
35

Enter a number: 407
407 is an Armstrong number
5
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
38

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
34
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
35

Độ phức tạp về thời gian: O [[logn] 2]O[[logn]2]

Không gian phụ trợ: O [1] O[1]

Phương pháp: Một số nguyên dương được gọi là số Armstrong nếu số lượng 3 chữ số của Armstrong, tổng số khối của mỗi chữ số bằng chính số. Ví dụ, 153 là một số Armstrong vì & nbsp; & nbsp; 153 = 1*1*1 + 5*5*5 + 3*3*3 & nbsp; & nbsp; Vòng lặp trong khi lặp lại như đầu tiên, nó kiểm tra xem số không bằng 0 hay không. Nếu nó không bằng 0 thì hãy nhập vào vòng lặp và tìm lời nhắc của số EX: 153%10 đưa ra lời nhắc 3. Trong bước tiếp theo, hãy thêm khối của một số vào SUM1 [3*3*3]. Sau đó, bước đưa ra thương số của số [153 // 10 = 15]. Vòng lặp này sẽ tiếp tục cho đến khi số đã cho bằng 0. & NBSP;A positive integer is called an Armstrong number if an Armstrong number of 3 digits, the sum of cubes of each digit is equal to the number itself. For example, 153 is an Armstrong number because
   153 = 1*1*1 + 5*5*5 + 3*3*3
    The while loop iterates like first, it checks if the number is not equal to zero or not. if it is not equal to zero then enter into the loop and find the reminder of number ex: 153%10 gives reminder 3. In the next step add the cube of a number to the sum1[3*3*3]. Then the step gives the quotient of the number [153//10=15]. this loop will continue till the given number is equal to zero.
 

Python3

abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4 ________ 133 & nbsp;

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
44
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
46

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
47
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
49
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
50
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
51
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
52

def7

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
6

abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
5
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
57
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
6
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
7

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
07
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
1
# Python program to check if the number is an Armstrong number or not

# take input from the user
num = int[input["Enter a number: "]]

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** 3
   temp //= 10

# display the result
if num == sum:
   print[num,"is an Armstrong number"]
else:
   print[num,"is not an Armstrong number"]
4
The given number 153 is armstrong number
2

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1def7
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
70
Input : 153
Output : Yes
153 is an Armstrong number.
1*1*1 + 5*5*5 + 3*3*3 = 153

Input : 120
Output : No
120 is not a Armstrong number.
1*1*1 + 2*2*2 + 0*0*0 = 9

Input : 1253
Output : No
1253 is not a Armstrong Number
1*1*1*1 + 2*2*2*2 + 5*5*5*5 + 3*3*3*3 = 723

Input : 1634
Output : Yes
1*1*1*1 + 6*6*6*6 + 3*3*3*3 + 4*4*4*4 = 1634
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
72
Enter a number: 663
663 is not an Armstrong number
7
Enter a number: 663
663 is not an Armstrong number
7
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
75

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
abcd... = pow[a,n] + pow[b,n] + pow[c,n] + pow[d,n] + .... 
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
The given number 153 is armstrong number
5
Enter a number: 663
663 is not an Armstrong number
3
Enter a number: 663
663 is not an Armstrong number
3
The given number 153 is armstrong number
2

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
2
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
44
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
4
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
87

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
34
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
50
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
91
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
92
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
93
Enter a number: 407
407 is an Armstrong number
2

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
95
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
7

153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
1
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
34
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
50
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
91
153 = 1*1*1 + 5*5*5 + 3*3*3  // 153 is an Armstrong number.
92
# Python program to check if the number is an Armstrong number or not

# take input from the user
num = int[input["Enter a number: "]]

# initialize sum
sum = 0

# find the sum of the cube of each digit
temp = num
while temp > 0:
   digit = temp % 10
   sum += digit ** 3
   temp //= 10

# display the result
if num == sum:
   print[num,"is an Armstrong number"]
else:
   print[num,"is not an Armstrong number"]
02
Enter a number: 407
407 is an Armstrong number
2

Đầu ra

The given number 153 is armstrong number

Vui lòng tham khảo đầy đủ bài viết về chương trình cho các số Armstrong để biết thêm chi tiết!

Độ phức tạp về thời gian: O [logn]O[logn]

Không gian phụ trợ: O [1] O[1]


Số Armstrong là gì?

Một số Armstrong là một số có tổng các chữ số được nâng lên cho sức mạnh ba bằng chính số.371, ví dụ, là một số Armstrong vì 3 ** 3 + 7 ** 3 + 1 ** 3 = 371.one whose sum of digits raised to the power three equals the number itself. 371, for example, is an Armstrong number because 3**3 + 7**3 + 1**3 = 371.

Số Armstrong giải thích với ví dụ là gì?

Một số lượng ba chữ số của Armstrong là một số nguyên sao cho tổng của các khối của các chữ số của nó bằng với chính số.Ví dụ: 371 là số Armstrong vì 3 ** 3 + 7 ** 3 + 1 ** 3 = 371. Viết một chương trình để tìm tất cả số Armstrong trong phạm vi 0 và 999.an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371. Write a program to find all Armstrong number in the range of 0 and 999.

Giá trị Armstrong là gì?

Số Armstrong là một số bằng tổng số các chữ số của nó.Ví dụ 0, 1, 153, 370, 371 và 407 là các số Armstrong.a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.

Số Armstrong 4 chữ số là gì?

4 chữ số armstrong cho số 4 chữ số, mỗi chữ số sẽ được nâng lên sức mạnh thứ tư của họ để có được kết quả mong muốn.1634, 8208, 9474 là một vài ví dụ về số Armstrong 4 chữ số.every digit would be raised to their fourth power to get the desired result. 1634, 8208, 9474 are a few examples of a 4 digit armstrong number.

Bài Viết Liên Quan

Chủ Đề