[seqfan] Re: A109733

APPLEGATE, DAVID L (DAVID L) david at research.att.com
Sat Jan 30 17:15:46 CET 2016


Two small points:  First, in the body of the email there's a typo - "A190733" should be "A109733" to match the subject.
Second, the program has a bug - f(0) recursively calls f(0) resulting in an infinite recursion, and f(2) recursively calls f(0).
I believe this was caused by, at the last moment, changing the program to match the offset of 1 in the sequence by adding the "--n;".  The fix is to change "int k=f(n/2);" to "int k=f(n/2+1);"

-Dave

-----Original Message-----
From: SeqFan [mailto:seqfan-bounces at list.seqfan.eu] On Behalf Of David Wilson
Sent: Friday, January 29, 2016 8:25 PM
To: 'Sequence Fanatics Discussion list'
Subject: [seqfan] A109733

A C++ function for efficiently computing A190733.
Perhaps an MMA geek could translate and check.

int f(int n)
{
	--n;
	if (n == 0) return 53;
	int k = f(n/2);
	if (n%2 == 0)
	{
		if (k < 50) return 52;
		else return 53;
	}
	else
	{
		if (k < 50) return k + 8;
		else return k - 2;
	}
}


_______________________________________________

Seqfan Mailing list - http://list.seqfan.eu/


More information about the SeqFan mailing list