Paste: gcd
Author: | kib2 |
Mode: | factor |
Date: | Tue, 23 Dec 2008 17:21:00 |
Plain Text |
IN: testkib
USING: prettyprint io math kernel ;
: pgcd ( a b -- c )
2dup
/i dup
0 = [ drop swap drop ] [ drop swap pgcd ] if . ;
10 4 pgcd
Author: | kib2 |
Mode: | factor |
Date: | Tue, 23 Dec 2008 22:56:42 |
Plain Text |
IN: testkib
USING: prettyprint math math.order kernel ;
: pgcd ( a b -- c )
2dup
< [ swap ] when
2dup
mod dup
zero? [ drop min ]
[ min pgcd ] if ;
685 411 pgcd .
Author: | mrjbq7 |
Mode: | factor |
Date: | Wed, 24 Dec 2008 00:14:05 |
Plain Text |
: jgcd ( a b -- c )
dup zero?
[ drop ]
[ [ mod ] keep swap jgcd ]
if
;
New Annotation