<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
  <channel>
    <title>MaplePrimes - comments on Post, Ponder This</title>
    <link>http://www.mapleprimes.com/posts/43769-Ponder-This</link>
    <language>en-us</language>
    <copyright>2026 Maplesoft, A Division of Waterloo Maple Inc.</copyright>
    <generator>Maplesoft Document System</generator>
    <lastBuildDate>Sun, 14 Jun 2026 02:32:55 GMT</lastBuildDate>
    <pubDate>Sun, 14 Jun 2026 02:32:55 GMT</pubDate>
    <itunes:subtitle />
    <itunes:summary />
    <description>The latest comments added to the Post, Ponder This</description>
    <image>
      <url>http://www.mapleprimes.com/images/mapleprimeswhite.jpg</url>
      <title>MaplePrimes - comments on Post, Ponder This</title>
      <link>http://www.mapleprimes.com/posts/43769-Ponder-This</link>
    </image>
    <item>
      <title>A bit faster</title>
      <link>http://www.mapleprimes.com/posts/43769-Ponder-This?ref=Feed:MaplePrimes:Ponder This:Comments#comment80772</link>
      <itunes:summary>Nice improvement, Alec, thanks.  Slightly clearer, I think, and a bit faster is to replace trunc( (...)/i) with iquo( (...), i).  Faster yet (still not by much) is to replace the three calls to irem() with a single call that assigns a local variable.  One implementation is

&lt;pre&gt;
Sols3 := proc(b)
local A,i,j,k,arem,rem;
    arem := proc() rem := irem(b*j,i) end;
    A := table();
    A[1] := [$1..b-1];
    for i from 2 do
        A[i] := [seq](seq(b*j+k*i-rem
                          ,k = `if`(arem()=0,0,1) .. iquo(b-1+rem,i))
                      ,j = A[i-1]);
        if A[i] = [] then break fi
    od;
    i-1 = A[i-1]
end proc:
&lt;/pre&gt;</itunes:summary>
      <description>The latest comments added to the Post, Ponder This</description>
      <guid>80772</guid>
      <pubDate>Sat, 06 Aug 2005 19:32:18 Z</pubDate>
      <itunes:author>Joe
 Riel
</itunes:author>
      <author>Joe
 Riel
</author>
    </item>
    <item>
      <title>Base 16</title>
      <link>http://www.mapleprimes.com/posts/43769-Ponder-This?ref=Feed:MaplePrimes:Ponder This:Comments#comment80769</link>
      <itunes:summary>Meanwhile, I calculated a(16): 

39 = [18872900738885736149574055538327802527212537551, 60753927368683934227793588395570842550542338031, 89515749136034833729775437005460258167590093634]

Converted to hex, the numbers look like 

34E4A468166CD8604EC0F8106AB4326098286CF
AA44CE207C78FC30003C3CC0D8382E2078D07EF
FAE06678C2E884607EB8B4E0B0A0F0603420342</itunes:summary>
      <description>The latest comments added to the Post, Ponder This</description>
      <guid>80769</guid>
      <pubDate>Sun, 07 Aug 2005 00:06:18 Z</pubDate>
      <itunes:author>alec</itunes:author>
      <author>alec</author>
    </item>
    <item>
      <title>Even faster</title>
      <link>http://www.mapleprimes.com/posts/43769-Ponder-This?ref=Feed:MaplePrimes:Ponder This:Comments#comment86928</link>
      <itunes:summary>Thank you, Joe. Both things are good. The next improvement can be achieved by separating the loop in 2 parts, 

&lt;pre&gt;a:=proc(b)
local A,i,j,k,arem,brem,rem;
arem:=proc() rem:= irem(b*j,i); 
     seq(b*j+k*i-rem,k = `if`(rem=0,0,1) .. iquo(b-1+rem,i)) end;
brem:=proc() rem:=irem(b*j,i);
     if rem=0 then b*j elif b-1+rem&amp;lt;i then NULL else b*j+i-rem fi end;
A[1] := [$1..b-1];
for i from 2 to b-1 do
     A[i] := [seq](arem(), j = A[i-1]) od;
for i from b do 
     A[i] := [seq](brem(), j = A[i-1]);
     if A[i] = [] then break fi od;
i-1 = A[i-1]
end:&lt;/pre&gt;

</itunes:summary>
      <description>The latest comments added to the Post, Ponder This</description>
      <guid>86928</guid>
      <pubDate>Sun, 07 Aug 2005 12:34:34 Z</pubDate>
      <itunes:author>alec</itunes:author>
      <author>alec</author>
    </item>
    <item>
      <title>Something in common</title>
      <link>http://www.mapleprimes.com/posts/43769-Ponder-This?ref=Feed:MaplePrimes:Ponder This:Comments#comment80767</link>
      <itunes:summary>Looking at my user number, 135, Joe Riel's 84, and Thomas Richard's 50, I found out that we have something in common. 
&lt;code&gt;
gcd(50,84)=2
gcd(50,135)=5
gcd(84,135)=3
&lt;/code&gt;</itunes:summary>
      <description>The latest comments added to the Post, Ponder This</description>
      <guid>80767</guid>
      <pubDate>Mon, 08 Aug 2005 03:32:04 Z</pubDate>
      <itunes:author>alec</itunes:author>
      <author>alec</author>
    </item>
    <item>
      <title>Improved version for Dumb Kopf</title>
      <link>http://www.mapleprimes.com/posts/43769-Ponder-This?ref=Feed:MaplePrimes:Ponder This:Comments#comment90124</link>
      <itunes:summary>Correspondingly, here is the improved version of a1, 

&lt;pre&gt;a1:=proc(b)
local A,i,j,k,arem,rem,dig;
arem:=proc() rem:=irem(b*j,i); dig:=convert(j,base,b); 
     seq(`if`(member(k*i-rem,dig),NULL,b*j+k*i-rem),
          k = 1 .. iquo(b-1+rem,i)) end;
A[1] := [$1..b-1];
for i from 2 do
     A[i] := [seq](arem(), j = A[i-1]);
     if A[i] = [] then break fi od;
i-1 = A[i-1]
end:&lt;/pre&gt;

For decimal system, it works very fast, 

&lt;pre&gt;tt:=time(): a1(10); time()-tt;

                           9 = [381654729]

                                0.016&lt;/pre&gt;

In addition to the values in the worksheet, I calculated

&lt;pre&gt;a1(21);
                   18 = [509504810627259318940020]

a1(22);

                   19 = [5213608783930183587520297]

a1(23);

  21 = [3017921136920002608782486643, 3202513921881602294966195322,

        10912277070078955588719411381, 11506928512609494037599575154,

        19136629049078922486640055262, 19563154864313291881366262910,

        20927442077211608842020972981, 22095893110934309880723905997,

        24479055281091281744429147151, 26034588683899462487295851544,

        27944901128718982841182304058, 28236074834439966722409861288,

        30327538677373615144106864301, 30327538677373615144106864322,

        33286709815522787435710859625, 33637644479370238638607793874,

        39311846134353288073052119134]
&lt;/pre&gt;



</itunes:summary>
      <description>The latest comments added to the Post, Ponder This</description>
      <guid>90124</guid>
      <pubDate>Tue, 09 Aug 2005 23:50:49 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
    <item>
      <title>Using Compiler</title>
      <link>http://www.mapleprimes.com/posts/43769-Ponder-This?ref=Feed:MaplePrimes:Ponder This:Comments#comment90128</link>
      <itunes:summary>Now, compiled procedures should run much faster. Here is the first try, 

&lt;pre&gt;a2 := proc(b::integer[4], A::Array(datatype = integer[4]))::
integer[4];
local i::integer[4], j::integer[4], K::integer[4],
s::integer[4], r::integer[4];
    A[1] := 1;
    i := 2;
    K := 1;
    s := 1;
    while 0 &amp;lt; i do
        if s = 1 then
            r := irem(A[1], i);
            for j from 2 to i - 1 do r := irem(r*b + A[j], i)
            end do;
            r := irem(r*b, i);
            if r = 0 then
                A[i] := 0; K := max(K, i); i := i + 1
            elif b - 1 + r &amp;lt; i then i := i - 1; s := 0
            else A[i] := i - r; K := max(K, i); i := i + 1
            end if
        else
            if A[i] + i &amp;lt; b then
                A[i] := A[i] + i; i := i + 1; s := 1
            else i := i - 1
            end if
        end if
    end do;
    K
end proc:

a3:=Compiler:-Compile(a2):
A:=Array(1..100,datatype=integer[4]):
&lt;/pre&gt;

While a2 is slower than a, the compiled procedure a3 is much faster. For example, 

&lt;pre&gt;tt:=time(): a3(10,A); time()-tt;
                                  25
                                0.016&lt;/pre&gt;

It should be called as a3(b,A) where b is the base and A is a predefined Array with datatype=integer[4] and length greater than the expected maximal number of digits. It returns the maximal number of digits. In particular, for b from 17 to 21 the maximal number of digits has appeared to be 45, 48, 48, 52, 53.


</itunes:summary>
      <description>The latest comments added to the Post, Ponder This</description>
      <guid>90128</guid>
      <pubDate>Fri, 12 Aug 2005 04:41:53 Z</pubDate>
      <itunes:author>Alec Mihailovs</itunes:author>
      <author>Alec Mihailovs</author>
    </item>
  </channel>
</rss>