Post Reply 
Tupper's 'Self-referencing' Formula
05-19-2022, 02:31 PM (This post was last modified: 05-19-2022 07:50 PM by matalog.)
Post: #1
Tupper's 'Self-referencing' Formula
I have been trying to get Tupper's 'Self Referencing' Formula to plot on the Prime, just out of interest initially, and after I found out you can't, I wanted to do it even more.

This is a plot of Tupper's Formula, it has of course lost all meaning, as the Formula it plots isn't the Formula used to plot it. It was never self referencing anyway, as the main part of the Formula k, was never plotted in the result, but is the key to the 'bitmap' being plotted.

This contains a routine to divide an arbitrarily large integer by a given number that the calculator can handle, and with division by 2, binary numbers extracted. It is the latter that takes so much time here.

This isn't fast, and I have made it in faster ways, but it's shorter code, and for the time saving, not really a big difference.

Code:
EXPORT T2UP()
BEGIN
LOCAL k:="96093937991895888497167296212785275471500433966012930665150551927170280239526642​46896428421743507181212671537827706233559932372808741443078913259639413377234878​57735749823926629715517173716995165232890538221612403238855866184013235585136048​82869333790249145422928866708109618449609170518345406782773155170540538162738096​76025656250169814820834187831638491155902256100036523513703438744618483787372381​98224849863465033159410054974700593138339226497249461751545728366702369745461014​655997933798537483143786841806593422227898388722980000748404719";
       //   Divide long number by 17 and store by using lsd(k)
LOCAL A:=0;LOCAL B:=lsd(k,17);LOCAL C:=0;LOCAL D:=0;LOCAL E:=0;LOCAL B1:=B;LOCAL B2:="";LOCAL B3:=0;LOCAL NA:="";LOCAL DONE:=0;LOCAL CO:=0;LOCAL li:={};LOCAL pos:=1;LOCAL count:=0;
rect();
  REPEAT 
  B3:=EXPR(RIGHT(B,1));
IF CO<1799 THEN
    //  Divide long number by 2 and plot if it was odd.
  B:=lsd(B,2);
ELSE DONE:=1;
END;
    //  Plot each pixel 3x3 as it is extracted.
    IF B3 MOD 2 THEN
           FOR W FROM 0 TO 2 DO
            FOR H FROM 1 TO 3 DO
              PIXON_P(316-3*FLOOR(CO/17)+W,3*(CO MOD 17)+H,0);
            END;
           END;
    END;
    CO:=CO+1;
    UNTIL DONE OR ISKEYDOWN(4);
WAIT(-1);
END;

lsd(number,divisor)
 //  LongStringDivision will Divide a long string integer of ANY length by a  
 //  Number that the calcualator can handle, integer result only.
BEGIN
LOCAL ans:="";
LOCAL idx:=1;
LOCAL temp:=1;
temp:=number(idx)-48;
  WHILE temp<divisor DO
      temp:=temp*10+(number(idx+1)-48);
      idx:=idx+1;
  END;
  idx:=idx+1;
  WHILE size(number)>idx-1 DO
     ans:=ans+STRING(FLOOR(temp/divisor));
     temp:=(temp MOD divisor)*10+(number(idx)-48);
     idx:=idx+1;
  END;
  idx:=idx+1;
  ans:=ans+STRING(FLOOR(temp/divisor));
  IF size(ans)==0 THEN
    RETURN 0;
  ELSE
    RETURN ans;
  END;

END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Tupper's 'Self-referencing' Formula - matalog - 05-19-2022 02:31 PM



User(s) browsing this thread: 1 Guest(s)