05-19-2022, 02:31 PM
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.
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:="960939379918958884971672962127852754715004339660129306651505519271702802395266424689642842174350718121267153782770623355993237280874144307891325963941337723487857735749823926629715517173716995165232890538221612403238855866184013235585136048828693337902491454229288667081096184496091705183454067827731551705405381627380967602565625016981482083418783163849115590225610003652351370343874461848378737238198224849863465033159410054974700593138339226497249461751545728366702369745461014655997933798537483143786841806593422227898388722980000748404719";
// 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;