Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 539 | bpr | 1 | |
| 2 | !goto $wims_read_parm |
||
| 3 | |||
| 4 | :def |
||
| 5 | title=Greatest Common Divisor |
||
| 6 | synonyme=gcd |
||
| 7 | input=list |
||
| 8 | !exit |
||
| 9 | |||
| 10 | :proc |
||
| 11 | |||
| 12 | n=!itemcnt $formula |
||
| 13 | !if $n<=1 |
||
| 14 | result=$[$formula] |
||
| 15 | !exit |
||
| 16 | !endif |
||
| 17 | |||
| 18 | u=!item 1 of $formula |
||
| 19 | v=!item 2 of $formula |
||
| 20 | u=!rawmath $u |
||
| 21 | v=!rawmath $v |
||
| 22 | src=gcd($u,$v) |
||
| 23 | !if $n>2 |
||
| 24 | !for i=3 to $n |
||
| 25 | v=!item $i of $formula |
||
| 26 | v=!rawmath $v |
||
| 27 | src=gcd($src,$v) |
||
| 28 | !next i |
||
| 29 | !endif |
||
| 30 | |||
| 31 | result=!exec pari $src |
||
| 32 | !exit |
||
| 33 | |||
| 34 | :output |
||
| 35 | !htmlmath gcd($formula) = $result |
||
| 36 | . |
||
| 37 | !exit |
||
| 38 |