Personal tools
You are here: Home Members folder スタッフ 関数の実装(最大公約数)
XScale ブログ
« September 2010 »
Su Mo Tu We Th Fr Sa
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
About this blog
スタッフブログ
 
Document Actions

関数の実装(最大公約数)

B.B.S. を使うための関数を書いていきます。

まずは、最大公約数。これはユークリッドの互助法でいいでしょう。

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

これだけで完成です。

Category(s)
j@ウェブ屋
The URL to Trackback this entry is:
http://www.xscale-freak.com/Members/folder/staff/95a26570306e5b9f88c5-67005c0f516c500d6570/tbping
Add comment

You can add a comment by filling out the form below. Plain text formatting.

(Required)

Powered by Plone CMS, the Open Source Content Management System