This commit is contained in:
2025-06-22 21:41:12 +02:00
commit e1edc387da
7 changed files with 118 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
package body Logic is
-- @name Step
-- @return
-- @parameter N:Natural
-- @parameter O:Natural
-- @description Do one calculation step and safe the result to O.
procedure Step (N : Natural; O : out Natural) is
begin
if N mod 2 = 0 then
O := N / 2;
else
O := 3 * N + 1;
end if;
end Step;
-- @name Row
-- @return
-- @parameter N:Natural,Final
-- @description Calculate full row for design.
procedure Row (N : Natural; Final : out Natural) is
Old : Natural := N;
Update : Natural;
begin
while (Old < (Natural'Last / 3)) and (not (Old = 1)) loop
Step (Old, Update);
Old := Update;
end loop;
if not (Old = 1) then
Old := 1;
end if;
Final := Old;
end Row;
end Logic;
+19
View File
@@ -0,0 +1,19 @@
package Logic is
-- @name Step
-- @return
-- @parameter N:Natural
-- @parameter O:Natural
-- @description Do one calculation step and safe the result to O.
procedure Step (N : Natural; O : out Natural) with
Depends => (O => N), Pre => (N < (Natural'Last / 3));
-- @name Row
-- @return
-- @parameter N:Natural,Final
-- @description Calculate full row for design.
procedure Row (N : Natural; Final : out Natural) with
Depends => (Final => N), Pre => (N < (Natural'Last / 3)),
Post => (Final = 1);
end Logic;
+15
View File
@@ -0,0 +1,15 @@
with Logic; use Logic;
with Ada.Text_IO; use Ada.Text_IO;
procedure Spark_Mode is
A, B : Natural;
begin
A := 8_400;
Row (A, B);
Put_Line (B'Image);
end Spark_Mode;