jeudi 27 septembre 2012

Strange number 123456

To exclude I/O from this post I've modified code. So now it not only calculates factorials but also sums their digits and at last sums the sums of digits and as a result there's on one I/O operation. Lisp as usual behaving quite good. And a result of this code: is
Evaluation took:
  7.762 seconds of real time
  7.565354 seconds of total run time (7.363660 user, 0.201694 system)
  [ Run times consist of 0.399 seconds GC time, and 7.167 seconds non-GC time. ]
  97.46% CPU
  17,812,436,719 processor cycles
  177 page faults
  15,624,347,568 bytes consed
  
2652733
Almost similar results I've got from Go program:
Elapsed time: 4.509443s
2652733
But strangely Clojure, Haskell and Julia have got some very strange behavior. Till 12345! everything seems to be ok (though for Clojure it takes almost 1.5 sec to calculate while Lisp done it in 0.091 seconds of real time). But when we get 123456! Clojure needs almost 1 minute, Haskell and Julia just plainly refused to calculate. Even in case of Julia it was not so plainly cause it decided to eat almost all memory.

Aucun commentaire:

Enregistrer un commentaire