Advertisement
PonaFly

Untitled

May 17th, 2019
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. (define (pairgcd lst)
  2. (define (searching lest rez)
  3. (if (= (length lest) 2) (+ (gcd (car lest) (cadr lest)) rez)
  4. (searching (cdr lest) (+ (gcd (car lest) (cadr lest)) rez))))
  5. (searching lst 0))
  6. (define (Sol1 lst)
  7. (define newlst (permutations lst))
  8. (define (searching lest maxi)
  9.  
  10. (if (empty? (cdr lest)) (if (< (pairgcd maxi) (pairgcd (car lest))) (car lest) maxi)
  11. (if (<= (pairgcd (car lest)) (pairgcd maxi)) (searching (cdr lest) maxi)
  12. (searching (cdr lest) (car lest)))))
  13. (searching newlst (car newlst)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement