-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfactorial.html
More file actions
33 lines (30 loc) · 869 Bytes
/
factorial.html
File metadata and controls
33 lines (30 loc) · 869 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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://javaalmanac.io/almanac.min.css">
</head>
<body>
<div class="content" id="content">
<sandbox version="java17" mainclass="Factorial" preview="true" v-cloak>
<sandbox-source name="Factorial.java">
public class Factorial {
static int factorial(int n) {
if (n <= 1) {
return 1;
} else {
return n * factorial(n-1);
}
}
public static void main(String[] args) {
System.out.println("3! = " + Factorial.factorial(3));
System.out.println("33! = " + Factorial.factorial(33));
System.out.println("133! = " + Factorial.factorial(133));
}
}
</sandbox-source>
</sandbox>
</div>
<script src="https://javaalmanac.io/app/sandbox-bundle.js"></script>
<script>new Vue({ el: '#content' })</script>
</body>
</html>