Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
54
Task/Jacobsthal-numbers/XPL0/jacobsthal-numbers.xpl0
Normal file
54
Task/Jacobsthal-numbers/XPL0/jacobsthal-numbers.xpl0
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
func IsPrime(N); \Return 'true' if N is prime
|
||||
int N, I;
|
||||
[if N <= 2 then return N = 2;
|
||||
if (N&1) = 0 then \even >2\ return false;
|
||||
for I:= 3 to sqrt(N) do
|
||||
[if rem(N/I) = 0 then return false;
|
||||
I:= I+1;
|
||||
];
|
||||
return true;
|
||||
];
|
||||
|
||||
proc Jaco(J2); \Display 30 Jacobsthal (or -Lucas) numbers
|
||||
real J2, J1, J;
|
||||
int N;
|
||||
[RlOut(0, J2);
|
||||
J1:= 1.0;
|
||||
RlOut(0, J1);
|
||||
for N:= 2 to 30-1 do
|
||||
[J:= J1 + 2.0*J2;
|
||||
RlOut(0, J);
|
||||
if rem((N+1)/5) = 0 then CrLf(0);
|
||||
J2:= J1; J1:= J;
|
||||
];
|
||||
CrLf(0);
|
||||
];
|
||||
|
||||
real J, J1, J2, JO;
|
||||
int N;
|
||||
[Format(14, 0);
|
||||
Jaco(0.0);
|
||||
Jaco(2.0);
|
||||
J2:= 1.0;
|
||||
RlOut(0, 0.0);
|
||||
J1:= 1.0;
|
||||
RlOut(0, J1);
|
||||
for N:= 2 to 20-1 do
|
||||
[J:= (J1 + 2.0*J2);
|
||||
JO:= J*J1;
|
||||
RlOut(0, JO);
|
||||
if rem((N+1)/5) = 0 then CrLf(0);
|
||||
J2:= J1; J1:= J;
|
||||
];
|
||||
CrLf(0);
|
||||
J2:= 0.0; J1:= 1.0; N:= 0;
|
||||
loop [J:= J1 + 2.0*J2;
|
||||
if IsPrime(fix(J)) then
|
||||
[RlOut(0, J);
|
||||
N:= N+1;
|
||||
if rem(N/5) = 0 then CrLf(0);
|
||||
if N >= 10 then quit;
|
||||
];
|
||||
J2:= J1; J1:= J;
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue