########################################################################## # Copyright (C) 2006 Jaap Spies, jaapspies@gmail.com # Copyright (C) 2006 William Stein, wstein@gmail.com # # Distributed under the terms of the GNU General Public License (GPL): # # http://www.gnu.org/licenses/ ############################################################### def A111775(n): r""" This function returns the $n$-th number of Sloane's sequence A111775 Powers of 2 and (odd) primes can not be written as a sum of at least three consecutive integers. $a(n)$ strongly depends on the number of odd divisors of $n$ (A001227): Suppose $n$ is to be written as sum of $k$ consecutive integers starting with $m$, then $2n = k(2m + k - 1)$. Only one of the factors is odd. For each odd divisor of $n$ there is a unique corresponding $k$, $k=1$ and $k=2$ must be excluded. See: http://www.jaapspies.nl/mathfiles/problem2005-2C.pdf INPUT: n -- non negative integer OUTPUT: integer -- function value EXAMPLES: sage: A111775(15) 2 sage: A111775(1000) 3 sage: A111775(51) 2 sage: A111775(23) 0 sage: A111775(1) 0 sage: A111775(0) 0 AUTHOR: - Jaap Spies (2006-12-09) """ if n == 1 or n == 0: return 0 k = sum(i%2 for i in divisors(n)) # A001227, the number of odd divisors if n % 2 ==0: return k-1 else: return k-2 def A111775_list(N): return [A111775(i) for i in range(0,N+1)]