5 kyu
Going to zero or to infinity?
77 of 6,092g964
Description:
Consider the following numbers (where n!
is factorial(n)
):
u1 = (1 / 1!) * (1!)
u2 = (1 / 2!) * (1! + 2!)
u3 = (1 / 3!) * (1! + 2! + 3!)
...
un = (1 / n!) * (1! + 2! + 3! + ... + n!)
Which will win: 1 / n!
or (1! + 2! + 3! + ... + n!)
?
Are these numbers going to 0
because of 1/n!
or to infinity due
to the sum of factorials or to another number?
Task
Calculate (1 / n!) * (1! + 2! + 3! + ... + n!)
for a given n
, where n
is an integer greater or equal to 1
.
Your result should be within 10^-6 of the expected one.
Remark
Keep in mind that factorials grow rather rapidly, and you need to handle large inputs.
Hint
You could try to simplify the expression.
Mathematics
Algorithms
Similar Kata:
Stats:
Created | Jul 12, 2015 |
Published | Jul 12, 2015 |
Warriors Trained | 27557 |
Total Skips | 8138 |
Total Code Submissions | 117824 |
Total Times Completed | 6092 |
Ruby Completions | 133 |
Python Completions | 1552 |
JavaScript Completions | 837 |
Haskell Completions | 170 |
C# Completions | 381 |
Java Completions | 789 |
CoffeeScript Completions | 17 |
Clojure Completions | 54 |
TypeScript Completions | 207 |
C++ Completions | 643 |
PHP Completions | 156 |
Crystal Completions | 11 |
F# Completions | 44 |
C Completions | 489 |
Rust Completions | 267 |
Swift Completions | 93 |
Go Completions | 214 |
R Completions | 56 |
Shell Completions | 20 |
OCaml Completions | 30 |
Fortran Completions | 18 |
Elixir Completions | 43 |
Julia Completions | 39 |
Scala Completions | 77 |
PowerShell Completions | 12 |
Nim Completions | 9 |
Reason Completions | 5 |
Racket Completions | 22 |
Forth Completions | 13 |
Kotlin Completions | 104 |
Prolog Completions | 12 |
Haxe Completions | 9 |
COBOL Completions | 6 |
Elm Completions | 4 |
Erlang Completions | 9 |
NASM Completions | 9 |
D Completions | 4 |
Total Stars | 592 |
% of votes with a positive feedback rating | 85% of 857 |
Total "Very Satisfied" Votes | 642 |
Total "Somewhat Satisfied" Votes | 165 |
Total "Not Satisfied" Votes | 50 |