-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecursion.html
52 lines (43 loc) · 1.12 KB
/
recursion.html
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Javascript</title>
</head>
<body>
<h1>Hello bb</h1>
<div id="output"></div>
<script>
function func1(num,exp){
if (exp === 0){
return 1;
}
// second example it is like that 4x4x4x1=64
// 4 x exp=3-1=2
return num * func1(num,exp-1);
}
// function func2(num,exp){
// if (exp === 0)
// return 1;
// // 4 x exp=-2-1=1
// return num * func3(num,exp-1);
// }
// function func3(num,exp){
// if (exp === 0)
// return 1;
// // x 4 exp=1-1=0
// return num * func4(num,exp-1);
// }
// function func4(num,exp){
// if (exp === 0)
// return 1;
// alert("exponent to big!");
// // exp=0 entonces return= x 1 = 64
// }
var answer = func1(4,3);
output.innerHTML = answer;
</script>
</body>
</html>