av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

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://uogjgqi.cn/article/cososhj.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流