Ludic numbers: Difference between revisions

Added Easylang
m (syntax highlighting fixup automation)
(Added Easylang)
 
(5 intermediate revisions by 4 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 3,876 ⟶ 3,916:
[233, 235, 239]
</pre>
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="Quackery"> [ 0 over of
swap times
[ i 1+ swap i poke ]
1 split
[ dup 0 peek
rot over join unrot
over size over > while
1 - temp put
[] swap
[ behead drop
temp share split
dip join
dup [] = until ]
drop temp release
again ]
drop behead drop join ] is ludic ( n --> [ )
 
999 ludic
say "First 25 ludic numbers: "
dup 25 split drop echo
cr cr
say "There are "
size echo
say " ludic numbers less than 1000."
cr cr
25000 ludic
say "Ludic numbers 2000 to 2005: "
1999 split nip 6 split drop echo</syntaxhighlight>
 
{{out}}
 
<pre>First 25 ludic numbers: [ 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 ]
 
There are 142 ludic numbers less than 1000.
 
Ludic numbers 2000 to 2005: [ 21475 21481 21487 21493 21503 21511 ]</pre>
 
=={{header|Racket}}==
Line 4,619 ⟶ 4,698:
</pre>
 
=={{header|V (Vlang)}}==
{{trans|Go}}
<syntaxhighlight lang="v (vlang)">const max_i32 = 1<<31 - 1 // i.e. math.MaxInt32
// ludic returns a slice of ludic numbers stopping after
// either n entries or when max is exceeded.
Line 4,712 ⟶ 4,791:
{{trans|Go}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var ludic = Fn.new { |n, max|
Line 4,785 ⟶ 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,995

edits