Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This program runs for ~2 seconds:
- // $ time java -cp . x
- // 18307473085240
- // real 0m2.085s
- // user 0m2.080s
- // sys 0m0.008s
- import java.io.*;
- import java.util.*;
- public class x
- {
- public static void main (String[] args)
- throws Exception
- {
- Random r = new Random ();
- long n = 0;
- for (int i = 0; i < 10000; i++)
- for (int j = 0; j < 10000; j++)
- n += r.nextInt ();
- System.out.println (n);
- }
- }
- ;; This program runs for ~6 seconds:
- ;; $ time clojure1.3 3.clj
- ;; real 0m6.051s
- ;; user 0m6.208s
- ;; sys 0m0.036s
- (loop [result 0
- i 0]
- (if (< i 10000)
- (recur (+ result (loop [result 0
- j 0]
- (if (< j 10000)
- (recur (+ result (int (rand 1000)))
- (+ j 1))
- result)))
- (+ i 1))
- result))
Advertisement
Add Comment
Please, Sign In to add comment