5 kyu

Going to zero or to infinity?

860 of 6,128g964

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

Stats:

CreatedJul 12, 2015
PublishedJul 12, 2015
Warriors Trained27612
Total Skips8146
Total Code Submissions118302
Total Times Completed6128
Ruby Completions133
Python Completions1560
JavaScript Completions860
Haskell Completions170
C# Completions381
Java Completions790
CoffeeScript Completions17
Clojure Completions54
TypeScript Completions209
C++ Completions643
PHP Completions156
Crystal Completions11
F# Completions45
C Completions490
Rust Completions267
Swift Completions93
Go Completions215
R Completions56
Shell Completions20
OCaml Completions31
Fortran Completions18
Elixir Completions43
Julia Completions39
Scala Completions78
PowerShell Completions12
Nim Completions9
Reason Completions5
Racket Completions22
Forth Completions13
Kotlin Completions104
Prolog Completions12
Haxe Completions9
COBOL Completions6
Elm Completions4
Erlang Completions9
NASM Completions9
D Completions4
Total Stars595
% of votes with a positive feedback rating85% of 861
Total "Very Satisfied" Votes645
Total "Somewhat Satisfied" Votes166
Total "Not Satisfied" Votes50
Ad
Contributors
  • g964 Avatar
  • jhoffner Avatar
  • anter69 Avatar
  • kazk Avatar
  • Blind4Basics Avatar
  • Voile Avatar
  • FArekkusu Avatar
  • monadius Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • akar-0 Avatar
  • depial Avatar
Ad