1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

年が明けたので素因数分解してみた

Last updated at Posted at 2025-01-06

えー皆さん、あけましておめでとうございます。2025年になりましたので2025を素因数分解してみようと思いましたのでプログラムを作ってみました

year = 2025
prime = []
prm_dic = {}
for i in range(2, year+1, 1):
    cnt = 0
    for j in range(2, i, 1):
        if i % j == 0:
            cnt += 1
    if cnt == 0:
        prime.append(i)
while year != 1:
    for prm in prime:
        if year % prm == 0:
            try:
                prm_dic[prm] += 1
            except:
                prm_dic[prm] = 1
            year = year // prm
for key in prm_dic:
    print("("+str(key)+"^"+str(prm_dic[key])+")", end="")
(3^4)(5^2)

というわけで

3^4×5^2
年明けましておめでとうございます

年賀状書くときは句読点付けないようにしませう。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?