Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Almost-prime/Ada/almost-prime.ada
Normal file
25
Task/Almost-prime/Ada/almost-prime.ada
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
with Prime_Numbers, Ada.Text_IO;
|
||||
|
||||
procedure Test_Kth_Prime is
|
||||
|
||||
package Integer_Numbers is new
|
||||
Prime_Numbers (Natural, 0, 1, 2);
|
||||
use Integer_Numbers;
|
||||
|
||||
Out_Length: constant Positive := 10; -- 10 k-th almost primes
|
||||
N: Positive; -- the "current number" to be checked
|
||||
|
||||
begin
|
||||
for K in 1 .. 5 loop
|
||||
Ada.Text_IO.Put("K =" & Integer'Image(K) &": ");
|
||||
N := 2;
|
||||
for I in 1 .. Out_Length loop
|
||||
while Decompose(N)'Length /= K loop
|
||||
N := N + 1;
|
||||
end loop; -- now N is Kth almost prime;
|
||||
Ada.Text_IO.Put(Integer'Image(Integer(N)));
|
||||
N := N + 1;
|
||||
end loop;
|
||||
Ada.Text_IO.New_Line;
|
||||
end loop;
|
||||
end Test_Kth_Prime;
|
||||
Loading…
Add table
Add a link
Reference in a new issue