Project Euler Problem 63: Powerful digit counts【暴力】

PE其他解題報告請參考這裏,本題答案在留言首條

Powerful digit counts

Problem 63


The 5-digit number, 16807=7516807=7^5, is also a fifth power. Similarly, the 9-digit number, 134217728=89134217728=8^9, is a ninth power.

How many n-digit positive integers exist which are also an nth power?


題意:

問你存在多少n位數字,是某數的n次冪這種組合

分析:

暴力題,python大發好啊

參考代碼
cnt = 0
for i in range(1,1000):
    for j in range(1, 1000):
        l = len(str(pow(j, i)))
        if (l > i) :break
        if (l == i):
            cnt += 1
print(cnt)

閱讀好習慣:點贊 + 收藏~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章