-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path递归.html
36 lines (32 loc) · 842 Bytes
/
递归.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
<!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>Document</title>
</head>
<body>
<script>
function func(n) {
if (n == 0 || n == 1) {
return 1;
}
return arguments.callee(n - 1) + arguments.callee(n - 2);
}
var a = func(5);
console.log(a);
function sum(n) {
if (n == 1) {
return 1;
}
return arguments.callee(n - 1) + n;
}
console.log(sum(5));
function strrepeat(str, num) {
return new Array(num + 1).join(str);
}
console.log(strrepeat("hello", 3));
</script>
</body>
</html>