Arithmetic/Integer: Difference between revisions

Line 3,446:
(print "(modulo " a " " b ") => " (mod a b)) ; same as (modulo a b)
 
(import (owl math-extra))
(print "(expt " a " " b ") => " (expt a b))
(print "(+gcd 1" 3a 5" 7" 9)b ") ; ==> 25" (gcd a b))
(print "(-lcm 1" 3a 5" 7" 9)b ") ; ==> -23" (lcm a b))
 
; you can use more than two arguments for +,-,*,/ functions
(print (+ 1 3 5 7 9))
(print (- 1 3 5 7 9))
(print (* 1 3 5 7 9)) ; ==> 945 - same as (1*3*5*7*9)
(print (/ 1 3 5 7 9)) ; ==> 1/945 - same as (((1/3)/5)/7)/9
</lang>
{{out}}
Line 3,459 ⟶ 3,466:
(modulo 8 12) => 8
(expt 8 12) => 68719476736
(gcd 8 12) => 4
(lcm 8 12) => 24
25
-23
945
1/945
</pre>
 
Additional features:
<lang ol>
; you can use more than two arguments for +,-,*,/ functions
(print (+ 1 3 5 7 9)) ; ==> 25
(print (- 1 3 5 7 9)) ; ==> -23
(print (* 1 3 5 7 9)) ; ==> 945 - same as (1*3*5*7*9)
(print (/ 1 3 5 7 9)) ; ==> 1/945 - same as (((1/3)/5)/7)/9
</lang>
 
=={{header|Onyx}}==