login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A322919 Numbers k such that k and k-1 both first appear in the same power of 2 (in base 10). 1

%I #34 Aug 15 2021 15:35:01

%S 59,74,111,785,793,914,957,985,1070,1467,2019,2099,2332,2610,2934,

%T 3028,3083,3311,3334,3973,4198,4208,4334,4590,4689,4785,5247,5350,

%U 5535,6166,6335,6669,6761,7167,7340,7707,7980,8668,8990,9180,9840,11110,13096,16285,17418,18091,18361,19219,20522,21494,21827

%N Numbers k such that k and k-1 both first appear in the same power of 2 (in base 10).

%H David A. Corneth, <a href="/A322919/b322919.txt">Table of n, a(n) for n = 1..3106</a>

%e For instance 2019 is in the sequence since 2018 and 2019 both appear in 2^212 and neither appear in any smaller power of two.

%o (C)

%o #include <stdio.h>

%o int main() {

%o int n = 1000001; /* Highest term */

%o int p = 2; /* Powers of two. Test throughly if you change it. */

%o int r = 10; /* Base ten. Test throughly if you change it. */

%o char a[n];

%o int b,c,i,j,k,k2,l,lk,m,ok,ok2,u,d[7],f[n],g[n],v[n];

%o u = n;

%o for (j=0;j<n;j++) {

%o a[j] = v[j] = 0; /* corrected v[n] to v[j]. - _M. F. Hasler_, Jul 05 2021*/

%o f[j] = g[j] = -1;

%o }

%o a[0] = 1;

%o for (m=0;(m<n) && u;m++) {

%o for (j=0;j<n;j++) if (a[j]) b = j;

%o for (k=0;k<n;k++) {

%o k2 = k;

%o for (j=0;k2;j++) {

%o d[j] = k2 % r;

%o k2 /= r;

%o }

%o lk = j;

%o if (!j) {

%o d[0] = 0;

%o lk = 1;

%o }

%o ok2 = 0;

%o if ((f[k] == -1) && (lk<=b+1)) {

%o ok2 = 0;

%o for (l=b-lk+1;l>-1;l--) {

%o ok = 1;

%o for (j=lk-1;j>-1;j--) if (a[l+j] != d[j]) ok = 0;

%o if (ok) ok2 = 1;

%o }

%o if (ok2) {

%o f[k] = m;

%o u--;

%o }

%o }

%o if ((g[k]==-1) && (lk<=b+1)) {

%o ok = 1;

%o for (j=lk-1;j>-1;j--) if (a[b-lk+j+1] != d[j]) ok = 0;

%o if (ok) g[k] = m;

%o }

%o }

%o c = 0;

%o for (j=0;j<b+2;j++) {

%o a[j] = a[j]*p + c;

%o c = 0;

%o if (a[j] > r-1) {

%o c = a[j] / r;

%o a[j] %= r;

%o }

%o }

%o }

%o for (i=1;i<n;i++) if (f[i] == f[i-1]) printf("%d\n",i);

%o return(0);

%o }

%o (PARI) uptoQdigits(n) = {v = vector(10^n); p = 1/2; todo = 10^n; my(res = List());

%o for(i = 1, oo, p<<=1; process(p, n); if(todo <= 0, break)); for(i = 1, #v - 1,

%o if(v[i] == v[i+1], listput(res, i))); res}

%o process(p, n) = {my(dp = digits(p), vd, lp = logint(p, 2)); qdp = #dp; my(t = min(n, qdp)); for(qd = 1, t, for(j = 1, qdp - qd + 1, vd = fromdigits(vector(qd, i, dp[j+i-1])); if(v[vd + 1] == 0, v[vd + 1] = lp; todo--)))} \\ _David A. Corneth_, Dec 31 2018

%Y Indices of consecutive repeats in A030000.

%K nonn,base

%O 1,1

%A _Keith F. Lynch_, Dec 30 2018

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 18 22:18 EDT 2024. Contains 371782 sequences. (Running on oeis4.)