cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-3 of 3 results.

A109814 a(n) is the largest k such that n can be written as sum of k consecutive positive integers.

Original entry on oeis.org

1, 1, 2, 1, 2, 3, 2, 1, 3, 4, 2, 3, 2, 4, 5, 1, 2, 4, 2, 5, 6, 4, 2, 3, 5, 4, 6, 7, 2, 5, 2, 1, 6, 4, 7, 8, 2, 4, 6, 5, 2, 7, 2, 8, 9, 4, 2, 3, 7, 5, 6, 8, 2, 9, 10, 7, 6, 4, 2, 8, 2, 4, 9, 1, 10, 11, 2, 8, 6, 7, 2, 9, 2, 4, 10, 8, 11, 12, 2, 5, 9, 4, 2, 8, 10, 4, 6, 11, 2, 12, 13, 8, 6, 4, 10, 3, 2, 7, 11, 8, 2, 12
Offset: 1

Views

Author

Keywords

Comments

n is the sum of at most a(n) consecutive positive integers. As suggested by David W. Wilson, Aug 15 2005: 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 d of n there is a unique corresponding k = min(d,2n/d). a(n) is the largest among those k. - Jaap Spies, Aug 16 2005
The numbers that can be written as a sum of k consecutive positive integers are those in column k of A141419 (as a triangle). - Peter Munn, Mar 01 2019
The numbers that cannot be written as a sum of two or more consecutive positive integers are the powers of 2. So a(n) = 1 iff n = 2^k for k >= 0. - Bernard Schott, Mar 03 2019

Examples

			Examples provided by _Rainer Rosenthal_, Apr 01 2008:
1 = 1     ---> a(1) = 1
2 = 2     ---> a(2) = 1
3 = 1+2   ---> a(3) = 2
4 = 4     ---> a(4) = 1
5 = 2+3   ---> a(5) = 2
6 = 1+2+3 ---> a(6) = 3
a(15) = 5: 15 = 15 (k=1), 15 = 7+8 (k=2), 15 = 4+5+6 (k=3) and 15 = 1+2+3+4+5 (k=5). - _Jaap Spies_, Aug 16 2005
		

Crossrefs

Cf. A000079 (powers of 2), A000217 (triangular numbers).

Programs

  • Maple
    A109814:= proc(n) local m, k, d; m := 0; for d from 1 by 2 to n do if n mod d = 0 then k := min(d, 2*n/d): fi; if k > m then m := k fi: od; return(m); end proc; seq(A109814(i),i=1..150); # Jaap Spies, Aug 16 2005
  • Mathematica
    a[n_] := Reap[Do[If[OddQ[d], Sow[Min[d, 2n/d]]], {d, Divisors[n]}]][[2, 1]] // Max; Table[a[n], {n, 1, 102}]
  • Python
    from sympy import divisors
    def a(n): return max(min(d, 2*n//d) for d in divisors(n) if d&1)
    print([a(n) for n in range(1, 103)]) # Michael S. Branicky, Dec 23 2022
  • Sage
    [sloane.A109814(n) for n in range(1,20)]
    # Jaap Spies, Aug 16 2005
    

Formula

From Reinhard Zumkeller, Apr 18 2006: (Start)
a(n)*(a(n)+2*A118235(n)-1)/2 = n;
a(A000079(n)) = 1;
a(A000217(n)) = n. (End)

Extensions

Edited by N. J. A. Sloane, Aug 23 2008 at the suggestion of R. J. Mathar

A111787 a(n) is the least k >= 3 such that n can be written as sum of k consecutive integers. a(n)=0 if such a k does not exist.

Original entry on oeis.org

0, 0, 0, 0, 0, 3, 0, 0, 3, 4, 0, 3, 0, 4, 3, 0, 0, 3, 0, 5, 3, 4, 0, 3, 5, 4, 3, 7, 0, 3, 0, 0, 3, 4, 5, 3, 0, 4, 3, 5, 0, 3, 0, 8, 3, 4, 0, 3, 7, 5, 3, 8, 0, 3, 5, 7, 3, 4, 0, 3, 0, 4, 3, 0, 5, 3, 0, 8, 3, 5, 0, 3, 0, 4, 3, 8, 7, 3, 0, 5, 3, 4, 0, 3, 5, 4, 3, 11, 0, 3, 7, 8, 3, 4, 5, 3, 0, 7, 3, 5, 0, 3, 0, 13
Offset: 1

Views

Author

Jaap Spies, Aug 16 2005

Keywords

Comments

a(n)=0 if n is an odd prime or a power of 2. For numbers of the third kind we proceed as follows: suppose n is to be written as sum of k consecutive integers starting with m, then 2n = k(2m + k - 1). Let p be the smallest odd prime divisor of n then a(n) = min(p,2n/p).

Examples

			a(15)=3 because 15=4+5+6 (k=3) and 15=2+3+4+5 (k=4)
		

References

  • Nieuw Archief voor Wiskunde 5/6 nr. 2 Problems/UWC Problem C part 3, Jun 2005, pp. 181-182

Crossrefs

Programs

  • Maple
    ispoweroftwo := proc(n) local a, t; t := 1; while (n > t) do t := 2*t end do; if (n = t) then a := true else a:= false end if; return a;end proc; A111787:= proc(n) local d, k; k:=0; if isprime(n) or ispoweroftwo(n) then return(0); fi; for d from 3 by 2 to n do if n mod d = 0 then k:=min(d,2*n/d); break; fi; od; return(k); end proc; seq(A111787(i),i=1..150);

A202238 Characteristic function of positive integers not prime and not a power of 2.

Original entry on oeis.org

0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1
Offset: 1

Views

Author

Michael Somos, Dec 16 2011

Keywords

Crossrefs

Programs

  • PARI
    {a(n) = n>0 && !isprime(n) && n != 2^valuation(n, 2)}
    
  • Python
    from sympy import isprime
    def A202238(n): return int(not isprime(n) and bool((n&-n)^n)) # Chai Wah Wu, Mar 11 2025

Formula

A111775(n) = 0 if and only if a(n) = 0.
A111787(n) = 0 if and only if a(n) = 0.
a(n) = 1 for n in A111774. - Michel Marcus, Aug 28 2017
Showing 1-3 of 3 results.