Block[{d,s,u,q,p,a,k,n},
Print["D = ",d=24009857226825282345490];
s=18;
u[0]=154951144645;
u[1]=10; 
u[2]=2;
u[3]=12;
u[4]=6;
u[5]=1;
u[6]=3;
u[7]=4;
u[8]=3;
u[9]=12;
(*remaining coefficients are symmetric*)
Do[u[s-i]=u[i],{i,1,s/2-1}];
u[s]=2u[0];
u[s+1]=u[1];
(*define sequences p[i] and q[i] by recurrences*)
q[-1]=0;
q[0]=1;
Do[q[i]=u[i]q[i-1]+q[i-2],{i,1,s}];
p[-1]=1;
p[0]=u[0];
Do[p[i]=u[i]p[i-1]+p[i-2],{i,1,s}];
Print["Continued fraction for D: ",
ContinuedFraction[Sqrt[d]]];
Print["D mod 4 = ",Mod[d,4]];
Print["factorization of D ",
FactorInteger[d]," so D is squarefree"];
(*define norm of alpha_i*)
n[i_]:=p[i]^2-d q[i]^2;
Print["Negative norms of convergents for i = 0, 2, 4, ..., 16: ",
Table[n[i],{i,0,s-2,2}]];
Print["The largest negative norm -N is attained for i = 2 (and, symmetrically, 14) and equals ",
Max[Table[n[i],{i,0,s,2}]]];
"Find all a such that -n[2] divides d-a^2";
Reduce[{d-a^2==-n[2]k},{a,k},Integers];
a=4030160489;
Print["Smallest a is ",a," and the bound from Jang-Kim's conjecture is (D-a^2)/N = ",
-(d-a^2)/n[2]];
(*define norm of alpha_{i,r}*)
n[i_,r_]:=(p[i]+r p[i+1])^2-d(q[i]+r q[i+1])^2;
Print["The list of norms N(alpha_{i,r}) of all indecomposables ",TableForm[Table[n[i,r],{i,-1,s-1,2},{r, 0, u[i+2]}],TableHeadings->{Table[i,{i,-1,s-1,2}], None}]];
Print["Maximal norm of an indecomposable is ",Max[Table[n[i,r],{i,-1,s-1,2},{r, 0, u[i+2]}]],", larger than Jang-Kim's bound."];
]