Palindromic gapful numbers: Difference between revisions
m
→{{header|Wren}}: Minor tidy
No edit summary |
m (→{{header|Wren}}: Minor tidy) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1,428:
{-------------Library Routines ----------------------------------------------------------------}
procedure GetDigits(N: integer; var IA: TIntegerDynArray);
{Get an array of the integers in a number}
{Numbers returned from least to most significant}
var T,I,DC: integer;
begin
DC:=Trunc(Log10(N))+1;
SetLength(IA,DC);
for I:=0 to DC-1 do
begin
T:=N mod 10;
N:=N div 10;
IA[I]:=T;
end;
end;
function GetNKPalindrome(N,K: int64): int64;
Line 3,442 ⟶ 3,455:
=== Ludicrously fast to 10,000,000,000,000,000,000th ===
{{libheader|Phix/online}}
You can run this online [http://phix.x10.mx/p2js/pgn.htm here].
<!--<syntaxhighlight lang="phix">(phixonline)-->
Line 3,580 ⟶ 3,594:
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">else</span>
<span style="color: #0000FF;">{</span><span style="color: #000000;">pals</span><span style="color: #0000FF;">,</span><span style="color: #000000;">palcount</span><span style="color: #0000FF;">,</span><span style="color: #000000;">skipn</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">palindromicgapfuls</span><span style="color: #0000FF;">(</span><span style="color: #000000;">pals</span><span style="color: #0000FF;">,</span>
<span style="color: #000000;">skip</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">skipn</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
Line 3,632 ⟶ 3,646:
<!--</syntaxhighlight>-->
{{out}}
<pre style="font-size:
First 20 palindromic gapful numbers ending with:
1: 121 1001 1111 1221 1331 1441 1551 1661 1771 1881 1991 10901 11011 12221 13431 14641 15851 17171 18381 19591
Line 5,347 ⟶ 5,361:
{{libheader|Wren-fmt}}
Search limited to the first 100,000 palindromic gapful numbers as, beyond that, the numbers become too large (>= 2 ^ 53) to be accurately represented by Wren's Num type.
<syntaxhighlight lang="
var reverse = Fn.new { |s|
|