LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 3 years have passed since last update.

プログラミング問題集解答例(問8)

Posted at

問8

import math
def question8(n):
    res = []
    for i in range(2, round(math.sqrt(n)) + 1):
        if (n%i) == 0:
            res.append(i)
            if i != n / i:
                res.append(int(n / i))
    return sorted(res)
n = 60
question8(n)
[2, 3, 4, 5, 6, 10, 12, 15, 20, 30]
n = 136
question8(n)
[2, 4, 8, 17, 34, 68]
n = 8075
question8(n)
[5, 17, 19, 25, 85, 95, 323, 425, 475, 1615]
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