0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Project Euler】Problem 63: べき乗の桁数

Posted at
  • 本記事はProjectEulerの「100番以下の問題の説明は記載可能」という規定に基づいて回答のヒントが書かれていますので、自分である程度考えてみてから読まれることをお勧めします。

問題 63. べき乗の桁数

原文 Problem 63: Powerful digit sum

問題の要約:$a^n$の桁数が$n$になるような$a^n$の個数を求めよ

例:

  • $16807=7^5, 134217728=8^9$

$a$の上限が9, $n$の上限が21であることが分かれば後は簡単です。

print(f"Answer: {sum([len(str(a**n)) == n for a in range(1,10) for n in range(1,22)])}")

(開発環境:Google Colab)

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?