日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python程序:檢查數(shù)字是否是Krishnamurthy數(shù)字

創(chuàng)新互聯(lián)python教程:

亳州網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),亳州網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為亳州成百上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個售后服務(wù)好的亳州做網(wǎng)站的公司定做!

編寫一個 Python 程序來檢查這個數(shù)字是不是一個 Krishnamurthy 數(shù)字,或者是否使用 while 循環(huán)。如果數(shù)的階乘之和等于它自己,那么任何數(shù)都是 Krishnamurthy 數(shù)。在這個 Python 例子中,我們使用 while 循環(huán)將數(shù)字分成數(shù)字。接下來,數(shù)學(xué)階乘函數(shù)找到每個數(shù)字的階乘。if 條件檢查單個數(shù)字的階乘之和是否等于一個數(shù)字。如果是真的,這是一個 Krishnamurthy 數(shù)字。

import math

Number = int(input("Enter the Number to Check Krishnamurthy Number = "))
Temp = Number
Sum = 0

while Temp > 0:
    fact = 1
    i = 1
    rem = Temp % 10
    fact = math.factorial(rem)
    Sum = Sum + fact
    Temp = Temp // 10

if Sum == Number:
    print("\n%d is a Krishnamurthy Number." %Number)
else:
    print("%d is Not a Krishnamurthy Number." %Number)

在這個 Python 示例中,我們移除了數(shù)學(xué)階乘函數(shù),并使用嵌套的 while 循環(huán)來檢查該數(shù)是否是 Krishnamurthy 數(shù)。

Number = int(input("Enter the Number to Check Krishnamurthy Number = "))
Sum = 0
Temp = Number

while Temp > 0:
    fact = 1
    i = 1
    rem = Temp % 10

    while i <= rem:
        fact = fact * i
        i = i + 1
    print('Factorial of %d = %d' %(rem, fact))
    Sum = Sum + fact
    Temp = Temp // 10

print("The Sum of the Digits Factorials = %d" %Sum)

if Sum == Number:
    print("\n%d is a Krishnamurthy Number." %Number)
else:
    print("%d is Not a Krishnamurthy Number." %Number)
Enter the Number to Check Krishnamurthy Number = 40585
Factorial of 5 = 120
Factorial of 8 = 40320
Factorial of 5 = 120
Factorial of 0 = 1
Factorial of 4 = 24
The Sum of the Digits Factorials = 40585

40585 is a Krishnamurthy Number.

標(biāo)題名稱:Python程序:檢查數(shù)字是否是Krishnamurthy數(shù)字
網(wǎng)站網(wǎng)址:http://www.5511xx.com/article/cososhj.html