Advertisement
OakEsteban

Untitled

Aug 8th, 2020 (edited)
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.58 KB | None | 0 0
  1. ;;Autor: Joann Esteban Bedoya
  2. ;;Fecha: agosto 8 de 2020
  3. ;;Contrato: multiplicacion: numero, numero >> numero
  4. ;;proposito: suma b veces a
  5.  
  6. (define (multiplicacion a b)( cond
  7.  
  8.   [(= b 1) a]
  9.  
  10.   [else (+ a (multiplicacion a (- b 1)) )]
  11.  
  12.   ))
  13.  
  14. (check-expect (multiplicacion 4 5) 20)
  15.  
  16. ;--------------------------------------------------------------------------
  17. ;;contrato: elevar: numero, numero >> numero
  18. ;;proposito: multiplica b veces a
  19.  
  20. (define (elevar a b) (cond
  21.  
  22.  [(= b 0) 1]
  23.  [else (* a (elevar a (- b 1)) )]
  24.  
  25.  
  26.                        ))
  27.  
  28.  
  29. (check-expect (elevar 2 5) 32)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement