日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Python程序:尋找一個(gè)數(shù)的質(zhì)因數(shù)

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

成都創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站制作、成都做網(wǎng)站、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)、呼中網(wǎng)絡(luò)推廣、小程序開發(fā)、呼中網(wǎng)絡(luò)營(yíng)銷、呼中企業(yè)策劃、呼中品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);成都創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供呼中建站搭建服務(wù),24小時(shí)服務(wù)熱線:13518219792,官方網(wǎng)址:www.cdcxhl.com

用 For 循環(huán)和 While 循環(huán)編寫一個(gè) Python 程序來(lái)尋找一個(gè)數(shù)的質(zhì)因數(shù),并給出一個(gè)例子。

用 For 循環(huán)求一個(gè)數(shù)的質(zhì)因數(shù)的 Python 程序

這個(gè) python 程序允許用戶輸入任何正整數(shù)。接下來(lái),Python 使用 For 循環(huán)返回該數(shù)的質(zhì)因數(shù)。

提示:建議大家參考一個(gè)數(shù)的因數(shù)、質(zhì)數(shù)的文章來(lái)理解這個(gè) python 程序的邏輯。

# Python Program to find Prime Factors of a Number

Number = int(input(" Please Enter any Number: "))

for i in range(2, Number + 1):
    if(Number % i == 0):
        isprime = 1
        for j in range(2, (i //2 + 1)):
            if(i % j == 0):
                isprime = 0
                break

        if (isprime == 1):
            print(" %d is a Prime Factor of a Given Number %d" %(i, Number))

使用 While 循環(huán)顯示一個(gè)數(shù)的質(zhì)因數(shù)的 Python 程序

這個(gè) Python 質(zhì)數(shù)因數(shù)程序和上面的一樣。在本 Python 示例中,我們將 For Loop 替換為 While Loop

# Python Program to find Prime Factors of a Number

Number = int(input(" Please Enter any Number: "))
i = 1

while(i <= Number):
    count = 0
    if(Number % i == 0):
        j = 1
        while(j <= i):
            if(i % j == 0):
                count = count + 1
            j = j + 1

        if (count == 2):
            print(" %d is a Prime Factor of a Given Number %d" %(i, Number))
    i = i + 1

Python 一個(gè)數(shù)的質(zhì)因數(shù)輸出

 Please Enter any Number: 250
 2 is a Prime Factor of a Given Number 250
 5 is a Prime Factor of a Given Number 250

文章題目:Python程序:尋找一個(gè)數(shù)的質(zhì)因數(shù)
當(dāng)前URL:http://www.dlmjj.cn/article/cdjhges.html