A081610 Number of numbers <= n having at least one 2 in their ternary representation.
0, 0, 1, 1, 1, 2, 3, 4, 5, 5, 5, 6, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 19, 20, 20, 20, 21, 22, 23, 24, 24, 24, 25, 25, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53
Offset: 0
Links
- Nathaniel Johnston, Table of n, a(n) for n = 0..10000
Programs
-
Maple
num2tern := proc(n) return numboccur(convert(n,base,3),2): end: a:=0: for n from 0 to 80 do a:=a+`if`(num2tern(n)>0,1,0): printf("%d, ",a): od: # Nathaniel Johnston, May 17 2011
-
Mathematica
Accumulate[Table[If[DigitCount[n,3,2]>0,1,0],{n,0,70}]] (* Harvey P. Dale, Aug 20 2012 *)
-
PARI
first(n)=my(s,t); vector(n,k,t=Set(digits(k,3)); s+=t[#t]==2) \\ Charles R Greathouse IV, Sep 02 2015
-
Python
from gmpy2 import digits def A081610(n): l = (s:=digits(n,3)).find('2') if l >= 0: s = s[:l]+'1'*(len(s)-l) return n-int(s,2) # Chai Wah Wu, Dec 05 2024
Formula
a(n) ~ n. - Charles R Greathouse IV, Sep 02 2015
Comments