Ludic numbers: Difference between revisions

m
(Ada version)
Line 367:
end Fill;
 
procedure Put_First_25Put_Lucid (First, Last : in Natural) is
use Ada.Text_IO;
begin
Put_Line ("Lucid numbers " & First'Image & " to " & 25Last'Image lucid& nunbers":");
for I in 1First .. 25Last loop
Put (Natural'(List (I))'Image);
end loop;
New_Line;
end Put_First_25Put_Lucid;
 
procedure Count_Below_1000Count_Lucid (Below : in Natural) is
Count : Natural := 0;
begin
for Lucid of List loop
if Lucid <= 1000Below then
Count := Count + 1;
end if;
end loop;
Ada.Text_IO.Put_Line ("There are " & Count'Image & " lucid numbers below 1000<=" & Below'Image);
end Count_Below_1000Count_Lucid;
 
procedure Put_From_2000_To_2005 is
use Ada.Text_IO;
begin
Put_Line ("Lucid nunbers 2000 to 2005:");
for I in 2000 .. 2005 loop
Put (Natural'(List (I))'Image);
end loop;
New_Line;
end Put_From_2000_To_2005;
 
procedure Find_Triplets (Limit : in Natural) is
 
function In_ListIs_Lucid (Value : in Natural) return Boolean is
begin
for X in 1 .. Limit loop
Line 408 ⟶ 398:
end loop;
return False;
end In_ListIs_Lucid;
 
use Ada.Text_IO;
X Index : Natural;
LuLucid : Natural;
begin
Put_Line ("All triplets of lucid numbers <" & Limit'Image);
XIndex := First_Index (List);
while List (XIndex) < Limit loop
LuLucid := List (XIndex);
if In_ListIs_Lucid (LuLucid + 2) and In_ListIs_Lucid (LuLucid + 6) then
Put ("(");
Put (LuLucid'Image);
Put (Natural'(LuLucid + 2)'Image);
Put (Natural'(LuLucid + 6)'Image);
Put_Line (")");
end if;
XIndex := XIndex + 1;
end loop;
end Find_Triplets;
Line 431 ⟶ 421:
begin
Fill;
Put_Lucid (First => 1,
Put_First_25;
Last => 25);
Count_Below_1000;
Count_Lucid (Below => 1000);
Put_From_2000_To_2005;
Put_Lucid (First => 2000,
Find_Triplets (250);
Last => 2005);
Find_Triplets (Limit => 250);
end Ludic_Numbers;</lang>
 
{{out}}
<pre>FirstLucid 25numbers lucid nunbers1 to 25:
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 lucid numbers below<= 1000
Lucid nunbersnumbers 2000 to 2005:
21475 21481 21487 21493 21503 21511
All triplets of lucid numbers < 250
210

edits