June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,8 +1,7 @@
left_fact = Enumerator.new do |y|
n, f, lf = 0, 1, 0
loop do
f, lf = 1, 0
1.step do |n|
y << lf #yield left_factorial
n += 1
lf += f
f *= n
end

View file

@ -1,8 +1,12 @@
left_fact = Enumerator.new do |y|
f, lf = 1, 0
1.step do |n|
y << lf #yield left_factorial
lf += f
f *= n
tens = 20.step(110, 10)
thousands = 1000.step(10_000, 1000)
10001.times do |n|
lf = left_fact.next
case n
when 0..10, *tens
puts "!#{n} = #{lf}"
when *thousands
puts "!#{n} has #{lf.to_s.size} digits"
end
end