RosettaCodeData/Task/Pathological-floating-point-problems/Crystal/pathological-floating-point-problems-4.cr

8 lines
196 B
Crystal
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
require "big"
e = 106246577894593683.to_big_d.div(39085931702241241.to_big_d)
balance = e - 1
1.upto(25) { |y| balance = (balance * y) - 1 }
puts "Bank balance after 25 years = #{balance.to_f}"