NSW Number

Author

Eric W. Weisstein
December 18, 2021

This notebook downloaded from http://mathworld.wolfram.com/notebooks/IntegerSequences/NSWNumber.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/NSWNumber.html.

©2021 Wolfram Research, Inc. except for portions noted otherwise

Definition

Select[Table[2 n^2,{n,100000}],IntegerQ[Sqrt[#-1]]&]

Sqrt[#-1]&/@%

NSWNumber[n_]:=LucasL[2n-1,2]/2

Table[NSWNumber[n],{n,10}]

Derivation

Reduce[2n^2==m^2+1&&(m|n)∈Integers&&m>0&&n>1,{m,n}]

m

FullSimplify[(1/2) (-(((3-2 (Sqrt[2])))^(C[1]))-(Sqrt[2]) (((3-2 (Sqrt[2])))^(C[1]))-(((3+2 (Sqrt[2])))^(C[1]))+(Sqrt[2]) (((3+2 (Sqrt[2])))^(C[1])))/.C[1]->n]

Table[(1/2) (-(((3-2 (Sqrt[2])))^n) (1+(Sqrt[2]))+(-1+(Sqrt[2])) (((3+2 (Sqrt[2])))^n)),{n,10}]//Expand

S[n_]:=(((((1+Sqrt[2]))^((2n-1)))+(((1-Sqrt[2]))^((2n-1))))/2)

S/@Range[10]//Expand

n

FullSimplify[(1/4) (2 (((3-2 (Sqrt[2])))^(C[1]))+(Sqrt[2]) (((3-2 (Sqrt[2])))^(C[1]))+2 (((3+2 (Sqrt[2])))^(C[1]))-(Sqrt[2]) (((3+2 (Sqrt[2])))^(C[1])))/.C[1]->n]

Table[(1/4) ((((3-2 (Sqrt[2])))^n) (2+(Sqrt[2]))-(-2+(Sqrt[2])) (((3+2 (Sqrt[2])))^n)),{n,10}]//Expand

S2[n_]:=(((((2+Sqrt[2]))^((2n-1)))+(((2-Sqrt[2]))^((2n-1))))/(2^(n+1)))

S2/@Range[10]//Expand

Recurrence

FullSimplify[RSolve[{s[n]==6s[n-1]-s[n-2],s[0]==1,s[1]==7},s[n],n]]

s[0]:=1
s[1]:=7
s[n_]:=s[n]=6s[n-1]-s[n-2]

Table[s[n],{n,0,10}]

t[n_]:=Expand[(1/2) (-(((3-2 (Sqrt[2])))^n) (-1+(Sqrt[2]))+(1+(Sqrt[2])) (((3+2 (Sqrt[2])))^n))]

Table[t[n],{n,0,10}]

Simplify[Table[t[n]==a t[n-1]+b t[n-2],{n,3}]]

Solve[%,{a,b}]

Primes

A113501

Position[Table[s[n],{n,1000}],_?PrimeQ]//Flatten//Timing

Select[Table[s[n],{n,200}],PrimeQ]

lpelllucas={2,3,4,5,7,8,16,19,29,47,59,163,257,421,937,947,1493,1901,6689,8087,9679,28753,79043,129127,145969,165799,168677,170413,172243};

(lpelllucas-1)/2

l=Select[%,IntegerQ]

Length[l]

primes={1,2,3,9,14,23,29,81,128,210,468,473,746,950,3344,4043,4839,14376,39521,64563,72984,82899,84338,85206,86121,139160};

TextGrid[MapIndexed[{#2[[1]],#,IntegerLength[NSWNumber[#]]}&,primes],Dividers->All,Alignment->Decimal]

Block[{$MaxExtraPrecision=10^5},IntegerLength[Round[((1+Sqrt[2])^(2l[[-1]]+1)+(1-Sqrt[2])^(2l[[-1]]+1))/2]]]

Block[{$MaxExtraPrecision=10^5},IntegerLength[Round[((1+Sqrt[2])^(2#+1)+(1-Sqrt[2])^(2#+1))/2]]&/@l]

Table[Round[((1+Sqrt[2])^(2i-1)+(1-Sqrt[2])^(2i-1))/2],{i,10}]

Select[%,PrimeQ]

Table[Round[((1+Sqrt[2])^(1+2l[[i]])+(1-Sqrt[2])^(1+2l[[i]]))/2],{i,5}]

Block[{$MaxExtraPrecision=10^6},
Do[Print[{{i,l[[i]]},IntegerLength[expr=Round[((1+Sqrt[2])^(2l[[i]]+1)+(1-Sqrt[2])^(2l[[i]]+1))/2]],PrimeQ[expr]//Timing}],{i,Length[l]}]
]