March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
15
Task/Modular-exponentiation/Scheme/modular-exponentiation.ss
Normal file
15
Task/Modular-exponentiation/Scheme/modular-exponentiation.ss
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(define (square n)
|
||||
(* n n))
|
||||
|
||||
(define (mod-exp a n mod)
|
||||
(cond ((= n 0) 1)
|
||||
((even? n)
|
||||
(remainder (square (mod-exp a (/ n 2) mod))
|
||||
mod))
|
||||
(else (remainder (* a (mod-exp a (- n 1) mod))
|
||||
mod))))
|
||||
|
||||
(define result
|
||||
(mod-exp 2988348162058574136915891421498819466320163312926952423791023078876139
|
||||
2351399303373464486466122544523690094744975233415544072992656881240319
|
||||
(expt 10 40)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue