Reply To: Programming
A Tale of 2 Secrets › Forums › T.E.M.P.E.S.T. › Programming › Reply To: Programming
@Robb27 ***WITH DUE RESPECT YOU POSTED A CORRECTION WHILE I WAS COMPOSING THIS REPLY***
#113175
You Gave Answer for W, X was asked for, but it implies that your answer is correct.
I do like to see others code, there is always a different way to code to achieve an
answer and sometimes I think why didn’t I think of that way, always learning.
Anyway here is my code for A RATHER LONLY NUMBER:
\\ PARI/GP Calculator Version 2.13.3 Code
\\ CODE – WITH UPPERCASE VARIABLES USED AS IN DESCIPTION
{
for(X=102,999999, \\ the range of X to check
d=digits(X); \\ change number to a vector of its digits
Y=d[#d]; \\ get last digit as multiplier
if(Y==0||Y==1,next); \\ if invalid end digit (0 or 1) goto next X
Z=X*Y; \\ compute for Z
W=vector(#d); \\ make W a vector (with places for all digits of X)
for(i=2,#d,W[i]=d[i-1]);W[1]=Y; \\ move X’s end digit onto front of X forms W
W=fromdigits(W); \\ convert W back to number
if(W==Z, \\ if W = Z then use next line to show reesult
print(“\nANSWER : “X”\nCheck : ” X” x “Y”\n = “W)))
}
ANSWER : 102564
Check : 102564 x 4
= 410256