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.

【Python】総和Σ(シグマ)と総乗Π(パイ)はループ文だったんだ!

Last updated at Posted at 2019-12-10

#はじめに
この記事は、僕が高校数学の復習をしているときに気づいた学習メモです。
高校数学が苦手のままエンジニアになり、
数学記号・数式から遠ざけてきた人間が学んだ中で得た小さな感動を誰かに伝えたくて書きました。

#この記事を読んでほしい方

  • Pythonの基礎文法が分かる人(Progateクリアレベル)
  • Σがいまいちピンとこない人
  • 数学が苦手な方

上記の方の一助となれば幸いです。

#総和 Σ

\sum_{i=1}^n i

Pythonで書くと、こんな形になる。

def total(start,end,step):
    temp =0
    for i in range(start,end+1,step):
        temp += i
    return temp

#総乗 Π

\prod_{i=1}^n i

Pythonで書くと、こんな形になる。

総乗Π
def product(start,end,step):
    temp=start
    for i in range(start,end+1,step):
        temp *= i
    return temp
3
3
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
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?