-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclase40plus.html
More file actions
36 lines (30 loc) · 885 Bytes
/
clase40plus.html
File metadata and controls
36 lines (30 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
//!6 = 6*5*4*3*2*1
function factorial(n) {
if (!this.cache) {
this.cache = {}
}
debugger
if (this.cache[n]) {
return this.cache[n]
}
if (n === 1) {
return 1
}
this.cache[n] = n * factorial(n - 1)
debugger
return this.cache[n]
}
//La memoización es una técnica de programación que nos permite ahorrar cómputo o procesamiento en JavaScript,
//al ir almacenando el resultado invariable de una función para que no sea necesario volver a ejecutar todas
//las instrucciones de nuevo, cuando se vuelva a llamar con los mismos parámetros. Es similar a usar memoria cache.
</script>
</body>
</html>