File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ (define countdown (lambda (n)
2+ (if (< n 101)
3+ (if (< n 1)
4+ 0
5+ (countdown (- n 1)))
6+ (countdown
7+ ((lambda (x)
8+ (countdown 100)
9+ (- x 100))
10+ n)))))
11+
12+ (countdown 10000)
13+ (countdown 10000)
14+ (countdown 10000)
15+ (countdown 10000)
16+
17+ (define start (now))
18+ (countdown 10000)
19+ (define end (now))
20+ (println (list (quote computation-time) (- end start)))
Original file line number Diff line number Diff line change 1+ function countdown(n) {
2+ if (n < 101) {
3+ if (n > 0) {
4+ countdown(n - 1);
5+ }
6+ } else {
7+ countdown(100);
8+ countdown(n - 100);
9+ }
10+ }
11+
12+ function main() {
13+ countdown(10000);
14+ countdown(10000);
15+ countdown(10000);
16+ countdown(10000);
17+
18+ start = nanoTime();
19+ countdown(10000);
20+ end = nanoTime();
21+ println("computation time: " + (end - start) / 1000000);
22+ }
You can’t perform that action at this time.
0 commit comments