/*
A117670.c
Copyright (C) June, 2012 Sergei Viznyuk
This program takes positive integer n as input.
The program prints OEIS sequence A117670 triangle.
The code is limited by LONG DOUBLE precision of math library routines.
This is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
*/
#include
#include
#include
#include
#ifdef __CYGWIN__
#define EXP exp
#define LGAMMA lgamma
#define LLROUND llround
#else
#define EXP expl
#define LGAMMA lgammal
#define LLROUND llroundl
#endif
static long long unsigned km(k,m)
long double k,m;
{ long long unsigned n=
LLROUND(EXP(LGAMMA(k+1.0L)-LGAMMA(k-m+1.0L)-LGAMMA(m+1.0L)));
if ( m > 1.0L ) n+=km(k,m-1.0L);
return n;
}
int main(int argn,char *argc[])
{ long unsigned n,i,j;
if ( argn!=2 )
{ fprintf(stderr,"Usage: %s \n",argc[0]); return -1; }
n=atol(argc[1]);
#if 0
include this if you want header in output
for (j=0;j