The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A040026 If n=r*2^s, r odd, then a(n)=t*r, where t is smallest (in magnitude) number such that 1=t*r+u*2^s. 1

%I #21 Nov 28 2023 16:29:36

%S 1,1,3,1,5,3,7,1,9,5,11,-3,13,7,15,1,17,9,19,5,21,11,23,9,25,13,27,-7,

%T 29,15,31,1,33,17,35,9,37,19,39,-15,41,21,43,-11,45,23,47,-15,49,25,

%U 51,13,53,27,55,-7,57,29,59,-15,61,31,63,1,65,33,67,17,69,35,71,9,73,37,75,-19

%N If n=r*2^s, r odd, then a(n)=t*r, where t is smallest (in magnitude) number such that 1=t*r+u*2^s.

%D J. Neukirch, Class Field Theory, Springer, p. 1.

%H Reinhard Zumkeller, <a href="/A040026/b040026.txt">Table of n, a(n) for n = 1..10000</a>

%e 24=3*2^3, 1=3*3-1*2^3, a(24)=3*3=9.

%t a[1] = a[2] = 1; a[n_?OddQ] := n; a[n_] := (s = IntegerExponent[n, 2]; r = n/2^s; eq = Reduce[1 == t*r + u*2^s, {t, u}, Integers] /. C[_] -> 0; t*r /. Solve[eq] // First ); Table[a[n], {n, 1, 76}] (* _Jean-François Alcover_, Jun 07 2013 *)

%o (C) for(n=1; n<=100; n++) { r=n; s=1; while((r&1)==0) { r>>=1; s<<=1; } for(t=1; t<9999; t++) { if(((t*r-1)%s)==0) { printf("%d,",t*r); break; } if(((t*r+1)%s)==0) { printf("%d,",-t*r); break; } } if((n%10)==0) printf("\n"); if(t==9999) exit(0); //"not found": error }

%o (Haskell)

%o a040026 n = f 1 where

%o f t | (1 - t*r) `mod` s == 0 = t*r

%o | (1 + t*r) `mod` s == 0 = - t*r

%o | otherwise = f (t + 1)

%o (r,s) = split n 1

%o split x y | m == 0 = split x' (2 * y)

%o | m == 1 = (x,y) where (x',m) = divMod x 2

%o -- _Reinhard Zumkeller_, Jul 21 2012

%Y |a(n)| differs from A000265, as a(24)=9.

%K sign,easy,nice,look

%O 1,3

%A _N. J. A. Sloane_

%E More terms from Arlin Anderson (starship1(AT)gmail.com)

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 May 24 18:59 EDT 2024. Contains 372781 sequences. (Running on oeis4.)