Problem_Set_07_Solutions_Code

Problem_Set_07_Solutions_Code - ; Discrete Math PS-7 ;...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
;;; Discrete Math PS-7 ;;; Shyam Visweswaran ;; Exercise 2 (define (extended-gcd a b) (cond ((= b 0) (list a 1 0)) (else (let ((lst (extended-gcd b (remainder a b)))) (list (car lst) (caddr lst) (- (cadr lst) (* (quotient a b) (caddr lst)))))))) (extended-gcd 233987973 41111687) ;Value: (1 -11827825 67318298) ;; the return value is of the form (gcd x y) ;; Exercise 9 - RSA encryption ;; the public key is (e, n) and the private key is (d, n) (define (encode e n lst) (cond ((null? lst) nil) (else (cons (modulo (expt (car lst) e) n) (encode e n (cdr lst)))))) (define (decode d n lst) (cond ((null? lst) nil) (else (cons (modulo (expt (car lst) d) n)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online