Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- // Termo por recorrĂȘncia
- // p(n+1) = 1+ ((n+1)*(n+2) /2)
- // p(n+1) = pn + (n+1)
- // pn = (2+n+n^2)/2
- /**
- *
- * 1 2 para baixo +2
- * 2 4 para baixo +3
- * 3 7 para baixo +4
- * 4 11
- */
- // pn = p(n-1) + n
- /**
- function numeroCortes(n) {
- if (n > 0)
- return n + numeroCortes(n - 1);
- else
- return 1;
- };
- **/
- /**
- let numeroCortes = (n) => {
- return (n > 0) ? (n + numeroCortes(n - 1)) : 1;
- };
- **/
- function numeroCortes(n) {
- return (n > 0) ? (n + numeroCortes(n - 1)) : 1;
- };
- console.log(numeroCortes(5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement