close
login
A138591
Sums of two or more consecutive nonnegative integers.
34
1, 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77
OFFSET
1,2
COMMENTS
Closely related to but different from A057716. - N. J. A. Sloane, May 16 2008
These are called polite numbers [From Howard Berman (howard_berman(AT)hotmail.com), Oct 29 2008] by those who require nonnegative integers in the definition as opposed to positive integers. With the latter requirement, 1 = 0 + 1 does not count as a polite number. [This difference of definition pointed out by Ant King (Nov 19 2010)] There is no disagreement that 1 belongs in this sequence, but there is disagreement as to whether it counts as a polite number. - Ant King, Nov 19 2010
Of course sums of two or more consecutive nonpositive integers have the same absolute values (noted while inserting "nonnegative" in title). All integers are sums of two or more consecutive integers without such restriction. - Rick L. Shepherd, Jun 03 2014
In K-12 education, these are known as "staircase numbers." The "1" is often omitted. - Gordon Hamilton, Mar 17 2015
Complement of A155559. - Ray Chandler, Mar 23 2016
Exactly the positive integers without nontrivial powers of two (i.e., 2^k, k > 0). That is, the same as A057716 except for the first term of both sequences. - M. F. Hasler, Jul 04 2025
REFERENCES
Elena Deza and Michel Marie Deza, Figurate numbers, World Scientific Publishing (2012), page 64.
A. Wah and H. Picciotto, Algebra: Themes, Tools, Concepts, 1994, page 190.
LINKS
Tom M. Apostol, Sums of Consecutive Positive Integers, The Mathematical Gazette, Vol. 87, No. 508, (March 2003).
Melfried Olson, Sequentially so, Mathematics Magazine 52:5, pp. 297-298.
Erzsébet Orosz, On odd-summing numbers, Acta Academiae Paedagogicae Agriensis, Sectio Mathematicae 31 (2004), pp. 125-129.
Henri Picciotto's Math Education Page, Staircases
PlanetMath, Polite number
Wai Yan Pong, Sums of consecutive integers, The College Mathematics Journal, 38 (2007), 119-123.
Wikipedia, Polite number
FORMULA
a(n) = n + A000523(n + A000523(n)). - Charles R Greathouse IV, Aug 12 2010
For n>1, a(n) = n+m if n+m > 2^m and a(n) = n+m-1 otherwise where m = floor(log_2(n-1))+1. - Chai Wah Wu, Nov 05 2025
EXAMPLE
0+1=1, 1+2=3, 2+3=5, 1+2+3=6, 3+4=7, 4+5=9, 1+2+3+4=10, ...
MATHEMATICA
1 + # + Floor[Log[2, # + 1 + Log[2, # + 1]]] &/@Range[0, 70] (* Ant King, Nov 18 2010 *)
PROG
(PARI) a(n)=n+logint(n+logint(n, 2), 2) \\ Charles R Greathouse IV, Sep 01 2015
(PARI) is(n)=n>>valuation(n, 2)>1 || n==1 \\ Charles R Greathouse IV, Aug 01 2016
(PARI) is_A138591(n)=hammingweight(n)>1||n==1 \\ M. F. Hasler, Jul 04 2025
(Python)
def A138591(n): return len(bin(n+len(bin(n))-3)) + n - 3 # Chai Wah Wu, Feb 18 2022
(Python)
A138591 = lambda n: n+(n+n.bit_length()-1).bit_length()-1
is_A138591 = lambda n: n.bit_count()>1 or n==1 # M. F. Hasler, Jul 04 2025
(Python)
def A138591(n): return n+m if n+(m:=(n-1).bit_length()) > 1<<m else n+m-1 if n>1 else 1 # Chai Wah Wu, Nov 05 2025
(C#) BigInteger a(BigInteger n) => (n + n.GetBitLength() - 1).GetBitLength() + n - 1; // Delbert L. Johnson, Mar 12 2023
CROSSREFS
Cf. A155559 (complement), A057716 (nonpowers of 2: essentially the same), A000079 (powers of 2).
Sequence in context: A229858 A269020 A057716 * A136492 A062506 A308468
KEYWORD
nonn,easy
AUTHOR
EXTENSIONS
More terms from Carl R. White, Jul 22 2009
STATUS
approved