A347475 Numbers k such that k and the k-th triangular number T(k) = k*(k+1)/2 have only odd digits.
1, 5, 13, 17, 177, 1777, 3937, 5537, 5573, 15173, 55377, 55733, 79137, 135173, 195937, 339173, 377777, 399377, 791377, 3397973, 5199137, 7913777, 13535137, 17397537, 33993973, 37735377, 39993777, 59591173, 59919137, 79971937, 135157537, 139713973, 153177777
Offset: 1
Examples
The numbers k = 1, 5, 13, 17, 177, 1777, ... have only odd digits, and the associated triangular numbers T(k) = k*(k+1)/2 = 1, 15, 91, 153, 15753, 1579753, 7751953, ... also have only odd digits. The same is true for k = 119311115937719393371311137, the smallest 27-digit term. Any number of the form n = 339{k}79{k}73{k} yields T(n) = A000217(n) = 79{k}19{k}13{k-1}453{k+1}5{k}1{k} and therefore is in the sequence, where {k} means k times (the preceding digit), for any k >= 1.
Links
- M. F. Hasler, Table of n, a(n) for n = 1..500, Sep 08 2022.
- S. S. Gupta, Can You Find (CYF) no. 55, Nov 11 2021, updated Sep 12 2022
- A. Zimmermann, Al Zimmermann's Programming Contests: Oddly Triangular, Sep. 7-8, 2022
Crossrefs
Programs
-
Mathematica
q[n_] := AllTrue[IntegerDigits[n], OddQ]; Select[Range[10^6], And @@ q /@ {#, #*(# + 1)/2} &] (* Amiram Eldar, Nov 20 2021 *)
-
PARI
apply( {A347475_row(n, t=10^n\9, L=List())=forvec(v=vector(n,i,[0,4]), is_A014261((1+n=t+fromdigits(v)*2)*n\2)&& listput(L,n));L}, [1..8]) \\ row(n) = terms with n digits. Use concat(%) to flatten the list.
-
PARI
A347475_first(n)=vector(n,i, n = next_A347475(n*(i>1)+1)) A347475_next(n)={my(t, p, f(v)=for(i=1, #v, bittest(v[i], 0) || return(10^(#v-i)))); while(((p=f(digits(n))) && !n+=p*10\9+if(p>99,22)-n%p) || p=f(digits(t=n*(n+1)\2)), n=max(sqrtint((t+p*10\9-t%p)*2), n+2));n} \\ used in A349247 A347475_prec(n)={my(t, p, f(v)=for(i=1, #v, bittest(v[i], 0) || return(10^(#v-i)))); while(((p=f(digits(n))) && !n-=n%p+if(p>99 && n\p%10, 23, 3)) || p=f(digits(t=n*(n+1)\2)), n=min(sqrtint((t-t%p-1)*2), n-2); if(n>p=n%100, n+=select(t->t<=p,[77,73,37,33,-23])[1]-p)); n} \\ used in A355277. - M. F. Hasler, Sep 13 2022
-
Python
from itertools import islice, count, product def A347345gen(): return filter(lambda k: set(str(k*(k+1)//2)) <= {'1','3','5','7','9'}, (int(''.join(d)) for l in count(1) for d in product('13579',repeat=l))) A347345_list = list(islice(A347345gen(),30)) # Chai Wah Wu, Dec 05 2021
-
Python
from math import isqrt def first_even(n): "Return 10^k corresponding to first even digit in n." for i,c in enumerate(n := str(n), 1): if c in "02468": return 10**(len(n)-i) def next_A347475(n): "Return the least term > n." if f := first_even(n := n+1): # next larger having only odd digits n += f*10//9 - n % f while f := first_even(t := n*(n+1)//2): if f := first_even(n := max(isqrt((t + 10*f//9 - t % f)*2), n+2)): n += 10*f//9 - n % f return n # M. F. Hasler, Sep 08 2022 N=1 # Example of use of the above function: for n in range(30): print(N := next_A347475(N), end=", ")
Comments