sequences that map from Z to N

14 views
Skip to first unread message

Ruud H.G. van Tol

unread,
Feb 8, 2026, 10:22:06 AM (5 days ago) Feb 8
to seq...@googlegroups.com

\\ (PARI)
fibs(n)= {
  [ fibonacci(i) |i<-[1..n]];
}

f(n, m=fibs(16))= {
  forstep(i=1,oo,2
  , my( d= Vecrev([ 2*b-1 |b<-binary(i)]));
    if( n == d * m[1..#d]~, return(i))
  );
}

p(n, m=primes(20))= {
  for(i=1,oo
  , my( d= Vecrev([ 2*b-1 |b<-binary(i)]));
    if( n == d * m[1..#d]~,return(i))
  );
}

{ print("f: ", [ f(n) | n<-[1..20]]); }
{ print("p: ", [ p(n) | n<-[1..20]]); }


should print:

f: [1, 3, 11, 7, 13, 23, 15, 27, 85, 29, 87, 31, 91, 55, 93, 59, 95, 61,
107, 63]
p: [2, 1, 10, 5, 3, 6, 11, 21, 43, 7, 13, 25, 14, 23, 46, 89, 15, 27,
47, 105]


* * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Q: Are those interesting sequences, to add to the OEIS?
* * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Examples:

f(1) =  1 =     1_2 = 1,
f(2) =  3 =    11_2 = 1 + 1 = 2,
f(3) = 11 =  1011_2 = 1 + 1 - 2 + 3 = 3,
f(4) =  7 =   111_2 = 1 + 1 + 2 = 4,
f(5) = 13 =  1101_2 = 1 - 1 + 2 + 3 = 5,
f(6) = 23 = 10111_2 = 1 + 1 + 2 - 3 + 5 = 6.

p(1) =  2 =    10_2 = - 2 + 3 = 1,
p(2) =  1 =     1_2 = 2,
p(3) = 10 =  1010_2 = - 2 + 3 - 5 + 7 = 3,
p(4) =  5 =   101_2 = 2 - 3 + 5 = 4,
p(5) =  3 =    11_2 = 2 + 3 = 5,
p(6) =  6 =   110_2 = - 2 + 3 + 5 = 6.

- - - - - - - - -

I'm not looking into mapping non-positive integers,
but f(0) would be -1 and p(0) would be -2
and f-term 10_2 = 2 would represent 1 - 1 = 0,
and p-term 100_2 = 4 would represent 5 - 3 - 2 = 0.

- - - - - - - - -

Some observations for the "fiblative" sequence:

For n > 0, f(n) == 1 (mod 2).

f( fibonacci(k) - 1 ) = (2^(k-2) - 1.
Example: f(34-1) = 127.

More mod-2^k counts:
{ my(v=vector(800,n,f(n))); [ #Set([ e%2^k |e<-v]) |k<-[1..12]] }
% [1, 2, 4, 7, 11, 19, 31, 48, 82, 133, 205, 349]

-- Ruud

Reply all
Reply to author
Forward
0 new messages