[seqfan] Re: More terms for A185074 (editing).
Richard Mathar
mathar at strw.leidenuniv.nl
Tue Mar 6 19:50:39 CET 2012
http://list.seqfan.eu/pipermail/seqfan/2012-March/016529.html
jl> Joerg Arndt feels that A185074 <https://oeis.org/A185074> (Number of
jl> representations of n in the form sum(i=1..n, c(i)/i ), where each of the
jl> c(i)'s is in {0,1,...,n}.), submitted recently, needs more terms before
I added 1274, 9443 and 54094 obtained with the following recursive Java program:
import java.math.* ;
class A185074 {
int n ;
A185074(int n)
{
this.n = n ;
}
static BigInteger factorial(int n)
{
BigInteger res = BigInteger.ONE ;
for(int i=2; i <= n ; i++)
res = res.multiply(new BigInteger(""+i)) ;
return res ;
}
int compute()
{
/* sum_i c(i)/i = n
* sum_i c(i)n!/i = n*n!
*/
BigInteger nfa = factorial(n) ;
return compute(1, nfa.multiply(new BigInteger(""+n)),nfa) ;
}
int compute(int lowi, BigInteger target, BigInteger nfa)
{
int cnt =0 ;
BigInteger su = BigInteger.ZERO ;
for(int c=0 ; c <= n ; c++)
{
su = new BigInteger(""+c).multiply(nfa).divide(new BigInteger(""+lowi)) ;
if ( su.compareTo(target) > 0 )
break;
if ( lowi == n)
{
if ( su.compareTo(target) == 0 )
cnt++;
}
else
cnt += compute(lowi+1, target.subtract(su), nfa) ;
}
return cnt ;
}
static public void main(String[] args)
{
for(int n=1; n < 100 ; n++)
{
A185074 oeis = new A185074(n) ;
System.out.println(n + " " + oeis.compute()) ;
}
}
}
More information about the SeqFan
mailing list