[英]I have a Python list of the prime factors of a number. How do I (pythonically) find all the factors?
[英]how do i get all the divisors of an input using its prime factors and multiplicities?
幾天來我一直在嘗試解決這個問題,但我仍然無法得到正確的 output。 問題是這樣的,例如,如果我使用數字 50,它有一個list [2, 5]
作為其prime factors
,並且這些factors
的相應multiplicities
性如下[1, 2]
prime_factors = [2, 5]
multiplicities = [1, 2]
所以divisors
應該有一個[1, 2, 5, 10, 25, 50]
的output
但這就是問題所在,我如何創建一個function
來獲取某個input
的所有divisors
,使用它的prime factors
和它們的對應輸入multiplicities
?
好吧,問題是“我如何編寫函數”,所以也許這些建議可以幫助你:
如果您被困在這些步驟中的任何一個上,這里的人會很樂意提供幫助,我們只需要有一個起點。 我建議寫出 output 中的每個元素及其來源。 祝你好運!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.