3
3

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 5 years have passed since last update.

Project Euler 29

Last updated at Posted at 2015-03-02

問題

2 ≤ a ≤ 52 ≤ b ≤ 5 について, a**b を全て考えてみよう:

2**2=4, 2**3=8, 2**4=16, 2**5=32
3**2=9, 3**3=27, 3**4=81, 3**5=243
4**2=16, 4**3=64, 4**4=256, 4**5=1024
5**2=25, 5**3=125, 5**4=625, 5**5=3125
これらを小さい順に並べ, 同じ数を除いたとすると, 15個の項を得る:

4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125

2 ≤ a ≤ 1002 ≤ b ≤ 100 で同じことをしたときいくつの異なる項が存在するか?
http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2029

回答

しいて言えばリスト内包表記の練習?かな?

def cof():
  seq = range(2,101)
  ans = len(set([x**y for x in seq for y in seq]))
  print ans
3
3
2

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?