Ludic numbers: Difference between revisions

Added Easylang
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
(Added Easylang)
 
(2 intermediate revisions by 2 users not shown)
Line 1,407:
=={{header|Delphi}}==
See [https://rosettacode.org/wiki/Ludic_numbers#Pascal Pascal].
 
=={{header|EasyLang}}==
{{trans|Nim}}
<syntaxhighlight>
proc initLudicArray n . res[] .
len res[] n
res[1] = 1
for i = 2 to n
k = 0
for j = i - 1 downto 2
k = k * res[j] div (res[j] - 1) + 1
.
res[i] = k + 2
.
.
initLudicArray 2005 arr[]
for i = 1 to 25
write arr[i] & " "
.
print ""
print ""
i = 1
while arr[i] <= 1000
cnt += 1
i += 1
.
print cnt
print ""
for i = 2000 to 2005
write arr[i] & " "
.
</syntaxhighlight>
{{out}}
<pre>
1 2 3 5 7 11 13 17 23 25 29 37 41 43 47 53 61 67 71 77 83 89 91 97 107
 
142
 
21475 21481 21487 21493 21503 21511
</pre>
 
=={{header|Eiffel}}==
Line 4,751 ⟶ 4,791:
{{trans|Go}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var ludic = Fn.new { |n, max|
Line 4,824 ⟶ 4,864:
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">def Size = 25000;
char Sieve(1+Size);
int I, Count, Ludic;
[\Make sieve for Ludic numbers
for I:= 1 to Size do Sieve(I):= true;
Ludic:= 2;
loop [I:= Ludic; Count:= Ludic;
loop [repeat I:= I+1;
if I > Size then quit;
until Sieve(I);
Count:= Count-1;
if Count = 0 then
[Sieve(I):= false;
Count:= Ludic;
];
];
repeat Ludic:= Ludic+1;
if Ludic > Size then quit;
until Sieve(Ludic);
];
\Show first 25 Ludic numbers
Count:= 0; I:= 1;
loop [if Sieve(I) then
[IntOut(0, I); ChOut(0, ^ );
Count:= Count+1;
if Count >= 25 then quit;
];
I:= I+1;
];
CrLf(0);
\Show how many Ludic numbers are <= 1000
Count:= 0;
for I:= 1 to 1000 do
if Sieve(I) then Count:= Count+1;
IntOut(0, Count);
CrLf(0);
\Show Ludic numbers from 2000 to 2005
Count:= 0; I:= 1;
loop [if Sieve(I) then
[Count:= Count+1;
if Count >= 2000 then
[IntOut(0, I); ChOut(0, ^ )];
if Count >= 2005 then quit;
];
I:= I+1;
];
CrLf(0);
\Show triplets of Ludic numbers < 250
for I:= 1 to 250-1-6 do
if Sieve(I) & Sieve(I+2) & Sieve(I+6) then
[ChOut(0, ^();
IntOut(0, I); ChOut(0, ^ );
IntOut(0, I+2); ChOut(0, ^ );
IntOut(0, I+6); Text(0, ") ");
];
CrLf(0);
]</syntaxhighlight>
{{out}}
<pre>
1 2 3 5 7 11 13 17 23 25 29 37 41 43 47 53 61 67 71 77 83 89 91 97 107
142
21475 21481 21487 21493 21503 21511
(1 3 7) (5 7 11) (11 13 17) (23 25 29) (41 43 47) (173 175 179) (221 223 227) (233 235 239)
</pre>
 
=={{header|zkl}}==
1,978

edits