OFFSET
1,1
COMMENTS
What is meant is the expansion in the factorial number system, cf. links. The formula itself is not sufficient to define the terms uniquely: a(n) can be decreased by any amount x if x*(n+1) is added to a(n+1). - M. F. Hasler, Nov 26 2018
LINKS
Hans Havermann, Table of n, a(n) for n = 1..10000
D. E. Knuth, The Art of Computer Programming, Vol.2, 3rd ed., Addison-Wesley, 2014, ISBN 978-0321635761, p.209.
Eric Weisstein's World of Mathematics, Harmonic Expansion
Wikipedia, Factorial number system
FORMULA
a(1)=3; for n >= 2, a(n) = floor(n!*Pi) - n*floor((n-1)!*Pi). - Benoit Cloitre, Mar 10 2002
EXAMPLE
Pi = 3/1! + 0/2! + 0/3! + 3/4! + 1/5! + ...
MAPLE
Digits := 120; M := proc(a, n) local i, b, c; b := a; c := [ floor(b) ]; for i from 1 to n-1 do b := b-c[ i ]/i!; c := [ op(c), floor(b*(i+1)!) ]; od; c; end: t1 := M(Pi, 100); A075874 := n->t1[n+1];
MATHEMATICA
p = N[Pi, 1000]; Do[k = Floor[p*n! ]; p = p - k/n!; Print[k], {n, 1, 75}]
With[{b = Pi}, Table[If[n == 1, Floor[b], Floor[n!*b] - n*Floor[(n - 1)!*b]], {n, 1, 100}]] (* G. C. Greubel, Nov 26 2018 *)
PROG
(PARI) x=Pi; vector(floor((y->y/log(y))(default(realprecision))), n, t=n!; k=floor(x*t); x-=k/t; k) \\ Charles R Greathouse IV, Jul 15 2011
(PARI) vector(30, n, if(n>1, t=t%1*n, t=Pi)\1) \\ Increase realprecision (e.g., \p500) to compute more terms. - M. F. Hasler, Nov 25 2018
(PARI) default(realprecision, 250); b = Pi; for(n=1, 80, print1(if(n==1, floor(b), floor(n!*b) - n*floor((n-1)!*b)), ", ")) \\ G. C. Greubel, Nov 26 2018
(Magma) SetDefaultRealField(RealField(250)); R:=RealField(); [Floor(Pi(R))] cat [Floor(Factorial(n)*Pi(R)) - n*Floor(Factorial((n-1))*Pi(R)) : n in [2..80]]; // G. C. Greubel, Nov 26 2018
(Sage)
def A075874(n):
if (n==1): return floor(pi)
else: return expand(floor(factorial(n)*pi) - n*floor(factorial(n-1)*pi))
[A075874(n) for n in (1..80)] # G. C. Greubel, Nov 26 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Robert G. Wilson v, Nov 02 2001 and Oct 20 2002
STATUS
approved