LoginSignup
1
1

More than 5 years have passed since last update.

Project Euler Q63 【べき乗の桁の個数】

Posted at

Project Eulerをワンライナーで解いてみる。
間違っていたらコメントください。

問題

$5$桁の数 $16807 = 7^5$は自然数を$5$乗した数である. 同様に$9$桁の数 $134217728 = 8^9$も自然数を$9$乗した数である.

自然数を $n$ 乗して得られる $n$ 桁の正整数は何個あるか?

解答

time seq 99 |
awk -M '{for(i=1;i<=99;i++){print i^$1,i,$1,length(i^$1)}}' |
awk '$3==$4' |
wc -l
49

real    0m0.250s
user    0m0.218s
sys     0m0.168s

$99$までで十分であることは誰も保証していない。
下記サイト様を確認すると$99$ですらやり過ぎであることが分かる。
Project Euler 63 - maple0705のブログ

が、一旦答えが出たのでよしとする。。

答え合わせ

こちらのサイト様と一致していればOKとした。
http://kingyojima.net/pje/063.html

1
1
0

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
1
1