Numbers with equal rises and falls: Difference between revisions
m
No need for Big_Integers. Big speed improvement!
(Ada version) |
m (No need for Big_Integers. Big speed improvement!) |
||
Line 253:
=={{header|Ada}}==
<lang Ada>with Ada.Text_Io;
with Ada.
procedure Equal_Rise_Fall is
use Ada.Text_Io;
function Has_Equal_Rise_Fall (Value :
Rises : Natural := 0;
Falls : Natural := 0;
Image : constant String :=
Last : Character := Image (Image'First + 1);
begin
for Pos in Image'First + 2 .. Image'Last loop
if Image (Pos) > Last then
Rises :=
elsif Image (Pos) < Last then
Falls :=
end if;
Last := Image (Pos);
Line 276 ⟶ 275:
end Has_Equal_Rise_Fall;
Value
Count
begin
loop
if Has_Equal_Rise_Fall (Value) then
Count :=
if Count <= 200 then
Ada.Integer_Text_Io.Put
if Count mod 20 = 0 then
New_Line;
Line 290 ⟶ 289:
if Count = 10_000_000 then
New_Line;
Put_Line ("The 10_000_000th: " &
exit;
end if;
end if;
Value :=
end loop;
end Equal_Rise_Fall;</lang>
{{out}}
<pre>
The 10_000_000th: 41909002</pre>
=={{header|ALGOL 68}}==
|