speed test php, python, ruby

preview_player
Показать описание
n! means n * (n-1) * ... * 3 * 2 * 1
For example 10! = 10 * 9 * 8 *...* 3*2*1 = 3628800
Let R(n) equal the sum of the digits in the number n!
For example, R(10) = 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27
Find the lowest value for n where R(n) is 8001

Configuration:
Debian squeeze 6.0.3
Kernel Linux 2.6.32
RAM: 4 GB
Processor: Pentium Dual-core E5700 @ 3 GHz

PHP 5.3.3-7+squeeze3
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
Рекомендации по теме
Комментарии
Автор

This is 2024, and ruby was improving their performance, and they now have other variant besides cruby, like jruby, truffleruby, mruby, even jit via yjit for cruby (mri).

ArcWeltraumpert
Автор

Just tested (7 years later) ruby example with ruby 2.5, took 0.3 seconds and no crashing. And python 3.5 example took 0.4 seconds. My CPU is 4.5 GHz.

music-bkee
Автор

These languages are not meant to give you fast performance they are meant to give you fast shipping

zadahmed
Автор

In PHP use gmp_fact and gmp_strval. Easy.

oisnot