% time python loop.py
6 6
28 28
220 284
496 496
1184 1210
2620 2924
5020 5564
6232 6368
8128 8128
python loop.py 36.03s user 0.00s system 98% cpu 36.459 total
% cat loop.cl (loop for a from 2 to 10000
do
(let ((sa 1))
(loop for d from 2 to (- a 2)
do
(when (= 0 (mod a d))
(incf sa d)))
(let ((b sa)
(sb 1))
(loop for d from 2 to (- b 2)
do
(when (= 0 (mod b d))
(incf sb d)))
(when (and (= sb a) (<= a b))
(format t "wesh ~a and ~a" a b)))))
time sbcl --noinform < loop.cl
* wesh 6 and 6wesh 28 and 28wesh 220 and 284wesh 496 and 496wesh 1184 and 1210wesh 2620 and 2924wesh 5020 and 5564wesh 6232 and 6368wesh 8128 and 8128
NIL
* sbcl --noinform < loop.cl 2.23s user 0.02s system 98% cpu 2.279 total
Bon, ben je suis toujours content d'utiliser CL le vendredi.
# À mon tour !
Posté par Axioplase ıɥs∀ (site web personnel) . En réponse au message Javascript plus rapide que python !. Évalué à 6.
% time python loop.py
6 6
28 28
220 284
496 496
1184 1210
2620 2924
5020 5564
6232 6368
8128 8128
python loop.py 36.03s user 0.00s system 98% cpu 36.459 total
% cat loop.cl
(loop for a from 2 to 10000
do
(let ((sa 1))
(loop for d from 2 to (- a 2)
do
(when (= 0 (mod a d))
(incf sa d)))
(let ((b sa)
(sb 1))
(loop for d from 2 to (- b 2)
do
(when (= 0 (mod b d))
(incf sb d)))
(when (and (= sb a) (<= a b))
(format t "wesh ~a and ~a" a b)))))
time sbcl --noinform < loop.cl
* wesh 6 and 6wesh 28 and 28wesh 220 and 284wesh 496 and 496wesh 1184 and 1210wesh 2620 and 2924wesh 5020 and 5564wesh 6232 and 6368wesh 8128 and 8128
NIL
* sbcl --noinform < loop.cl 2.23s user 0.02s system 98% cpu 2.279 total
Bon, ben je suis toujours content d'utiliser CL le vendredi.