gcd + lcm + weird bug
This commit is contained in:
parent
e083e173e8
commit
dad487fde3
12
demo.modal
12
demo.modal
|
@ -19,6 +19,7 @@
|
|||
<> ((binary 9)) ((1 (0 (0 (1 ())))))
|
||||
|
||||
-- ( binary to decimal digit )
|
||||
<> ((decimal ())) (0)
|
||||
<> ((decimal (0 ()))) (0)
|
||||
<> ((decimal (1 ()))) (1)
|
||||
<> ((decimal (0 (1 ())))) (2)
|
||||
|
@ -203,4 +204,13 @@
|
|||
<> ((pow ?x (0 ?k))) ((pow (mul ?x ?x) ?k))
|
||||
<> ((pow ?x (1 ?k))) ((mul ?x (pow (mul ?x ?x) ?k)))
|
||||
|
||||
(str (pow (int 13) (int 10)))
|
||||
-- ( greatest common denominator )
|
||||
<> ((gcd ?a ?b)) ((gcd1 ?a ?b (cmp ?b (0 ()))))
|
||||
<> ((gcd1 ?a ?b #eq)) (?a)
|
||||
<> ((gcd1 ?a ?b #gt)) ((gcd ?b (mod ?a ?b)))
|
||||
<> ((gcd1 ?a ?b #lt)) ((gcd ?b (mod ?a ?b)))
|
||||
|
||||
-- ( least common multiple )
|
||||
<> ((lcm ?a ?b)) ((mul ?a (div ?b (gcd ?a ?b))))
|
||||
|
||||
(str (lcm (int 1000) (int 777)))
|
||||
|
|
Loading…
Reference in New Issue