The Museum of HP Calculators

HP Forum Archive 19

 Mini Challenge from comp.sys.hp48Message #1 Posted by Egan Ford on 25 Mar 2010, 6:06 p.m. Just in case you missed it: Joe Horn said, Quote: It would *seem* that all integers raised to the 4th power contain at least one digit less than 5. For example, 26 to the 4th power is 456976, which contains a 4. However, there does exist a positive integer X such that X^4 contains no digits less than 5. Mini-challenge: Write a User-RPL program that finds the only (?) positive integer X such that X^4 contains no digits less than 5. Winner: Fastest solver that doesn't cheat. -Joe-

 Re: Mini Challenge from comp.sys.hp48Message #2 Posted by J-F Garnier on 26 Mar 2010, 1:42 p.m.,in response to message #1 by Egan Ford Found it! Unique solution, at least up to 1E6. Using Free42 (will not work on regular HP42): ```00 { 60-Byte Prgm } 01>LBL "MC" 02 1 03 STO 00 04>LBL 01 05 RCL 00 06 ENTER 07 × 08 ENTER 09 × 10>LBL 02 11 RCL ST X 12 10 13 MOD 14 5 15 X>Y? 16 GTO 03 17 Rv 18 - 19 10 20 ÷ 21 X#0? 22 GTO 02 23 "FOUND " 24 ARCL 00 25 AVIEW 26 STOP 27>LBL 03 28 RCL 00 29 1 30 + 31 STO 00 32 1E6 33 X>Y? 34 GTO 01 35 .END. ``` J-F

 Re: Mini Challenge from comp.sys.hp48Message #3 Posted by Gerson W. Barbosa on 26 Mar 2010, 4:51 p.m.,in response to message #2 by J-F Garnier Since n^4 ends in 1 for n ending in 1, 3, 7 and 9 and final 5 appear to always introduce either 0 or 2 in the answer, you can do it in half the time by replacing the '1' in lines 02 and 29 with '2'. Gerson.

 Re: Mini Challenge from comp.sys.hp48Message #4 Posted by Gerson W. Barbosa on 26 Mar 2010, 5:27 p.m.,in response to message #2 by J-F Garnier Is ENTER * faster than X^2? Even numbers ending in 0 can be handled by inserting X=0? and GTO 03 between lines 13 and 14, but the improvement (if any) is hard to notice on Free42. Gerson.

 Re: Mini Challenge from comp.sys.hp48Message #5 Posted by J-F Garnier on 26 Mar 2010, 5:38 p.m.,in response to message #4 by Gerson W. Barbosa You're right X^2 is just simpler... Free42 on PC, especially the binary version, is fast enough to find the solution in less than one second, but the decimal version is needed to check all numbers up to 1e6 thanks to the 25-digit accuracy. This is what I mostly appreciate with Free42: fast speed and enhanced accuracy versus the HP42S, and I like to be able to choose between speed (binary version) or accuracy (decimal version) depending on the problem. If only there was a Free71... J-F

 Re: Mini Challenge from comp.sys.hp48Message #6 Posted by Reth on 26 Mar 2010, 9:57 p.m.,in response to message #4 by Gerson W. Barbosa Also, why not: ```1 STO+ 00 RCL 00 ``` 42S on Iphone solves it almost instantly. Today I noticed 42S showing: 00 { 31-Line Prgm } rather than bytes, I guess it makes no difference using different methods of calculating x ^ 4 would change program running time.

 Re: Mini Challenge from comp.sys.hp48Message #7 Posted by Glenn Shields on 27 Mar 2010, 11:27 a.m.,in response to message #2 by J-F Garnier May I offer a program for the 50g as a "newb", not a fast, efficient or clever one, but as a service to others like me just new to RPL. I'm using the fact as given in the original post that the number can't end in 1,3,7 or 9, and the hint that it can be proven that 5 is excluded too. If this program wouldn't have found a solution in a reasonable time (and the real answer did end in 5), it could have been easily re-done to search for multiples of 5 (and more quickly). So this program churns through the even numbers in just under 20 minutes. Just store 0 in variable 'N' and then the answer is left there at the end. Again, pretty much a brute force program just to demonstrate some functions for my fellows wondering how one might begin to solve this challenge! << DO 2 'N' STO+ 'N^4' EVAL ->STR DUP SIZE -> s << 1 CF 1 s FOR i DUP HEAD SWAP TAIL SWAP OBJ-> IF 4 <= THEN 1 SF END NEXT DROP >> UNTIL 1 FC? END >> Happy programming! Regards, Glenn

 Re: Mini Challenge from comp.sys.hp48Message #8 Posted by Marcus von Cube, Germany on 27 Mar 2010, 7:05 p.m.,in response to message #7 by Glenn Shields You can of course exclude the even multiples of 5 but why the numbers simply ending in 5? I'd like to see a proof.

 Re: Mini Challenge from comp.sys.hp48Message #9 Posted by Glenn Shields on 27 Mar 2010, 9:55 p.m.,in response to message #8 by Marcus von Cube, Germany Looking at the beginnings of a proof for excluding 5, the "10a + b" term is suggested. If you multiply out (10a + b)^4 and simplify, and substitute b=5, you get the following arrangement: 10000a^4 + 10000a^3 + 25000a^2 + 5000a + 625. Notice if a = 1, you get 50625 (15^4). The "proof" comes in showing that the fourth- largest place is always 0. This is because the last two terms in the expansion have a 5 in the thousands place, and when a is even the two 5's become 0's in the sum, and the other terms all involve higher places. When a is odd, a^2 is also odd, and those two terms keep a 5 so then the two 5's add up to 0 again. Is this a formal proof? It seems to hold up. Anyway, a great challenge and it's what this forum is all about. Regards, Glenn

 Re: Mini Challenge from comp.sys.hp48Message #10 Posted by Glenn Shields on 27 Mar 2010, 10:18 p.m.,in response to message #9 by Glenn Shields Sorry, please see msg.#13 :-)

 Re: Mini Challenge from comp.sys.hp48Message #11 Posted by C.Ret on 27 Mar 2010, 7:45 p.m.,in response to message #7 by Glenn Shields Hello. This challenge triggers my curiosity. I am searching for a clever mathematical way of this interesting problem, but still clue less. Meanwhile, my attempt of a quite "brute force" search program lead me to the following RPL program that I run on my HP-28S (it is so simple that it will run on all RPL from 28C to 50g): ```« DO @ Do main loop 2 + @ looking only for even numbers DUP 1 DISP @ Optional display current number – slows research DUP SQ SQ @ Compute x^4 ->STR @ Convert to string 0 48 52 FOR c @ 48 to 52 are ASCII code for "0" to "52" OVER c CHR POS @ test if digit less than 5 present in "x^4" + @ equivalent to OR NEXT SWAP DROP @ remove "x^4" after tests UNTIL NOT @ sum of POS is 0 if none of the digits were found END » 'PRO1' STO ``` Usage: Enter starting number 0, the program simply stop leaving the answer in stack. Continue searching by simply re-running it, the previous value is kept in the stack. As every one may have notice, it is really close to the one Glenn Shields post previously. But, as same one may have notice, it is unable to search for number greater than 1000 ! Because of the 12 digit precision of HP-28S, the x^4 value is rounded and digits can’t be tested to the missing unit position ! 1000^4 = 1000000000000 which is 1.E+12 So I suggest that HP49/50g users use full precision arithmetic capabilities, and HP28/48 users binary number which may be efficient up to 65536 since largest binary of 64 bits is 2^64 which quadric root is 2^16. ```« 64 STWS DEC @ switch to decimal binary word full length DO #2d + @ looking only for even binary numbers DUP 1 DISP @ Optional display current number – slows research DUP DUP * DUP * @ Compute x^4: SQ not available with binary numbers ->STR 0 48 52 FOR c @ Search for 0 to 4 digit in "x^4" OVER c CHR POS + NEXT SWAP DROP @ UNTIL NOT @ sum is 0 for any solution END » ``` My HP-28S found the solution in 7 min (~6min without DUP 1 DISP). No other solution was found before reaching 65536 after a 2h30 run. Edited: 28 Mar 2010, 3:59 a.m. after one or more responses were posted

 Re: Mini Challenge from comp.sys.hp48Message #12 Posted by Glenn Shields on 27 Mar 2010, 9:04 p.m.,in response to message #11 by C.Ret Wow, C.Ret, I tried your program on the 50g (but without the second DUP in the third line) and got an amazing 1:59 time. Then I removed the DUP 1 DISP and got an even more amazing 1:48 (but it was more fun with the display). This is the cleverness I was looking for, great use of POS, CHR and NOT, these just blitz the other tests and string manipulations. This type of programming was given in examples in the user guides but it's great to see them applied in other ways. Great!!

 Re: Mini Challenge from comp.sys.hp48Message #13 Posted by Glenn Shields on 27 Mar 2010, 10:12 p.m.,in response to message #12 by Glenn Shields DUH!!!! Didn't that just prove that our number will always end in 0625? Now there are two nails for that coffin. Yup.

 Re: Mini Challenge from comp.sys.hp48Message #14 Posted by Marcus von Cube, Germany on 28 Mar 2010, 9:33 a.m.,in response to message #13 by Glenn Shields After a quick look at your formula I just decided to ignore the rest of your reasoning. Enough zeros in the factors to see the obvious. ;)

 Re: Mini Challenge from comp.sys.hp48Message #15 Posted by Chuck on 28 Mar 2010, 1:16 p.m.,in response to message #1 by Egan Ford Okay, I know this is an HP calculator challenge, but I had to give it a try with Mathematica. Here's the code: i = 2; While[Min[IntegerDigits[i^4]] < 5, i = i + 2] It found the solution in 0.009491 seconds. Darn quick. I also let it run until i was about 26,000,000; no more solutions found. CHUCK Edited: 28 Mar 2010, 1:20 p.m.

 Re: Mini Challenge from comp.sys.hp48Message #16 Posted by Gerson W. Barbosa on 28 Mar 2010, 5:37 p.m.,in response to message #15 by Chuck Quote: I also let it run until i was about 26,000,000; no more solutions found. Isn't this just a matter of probability? I think it is very unlikely new solutions are found as i increases although this is not impossible. For instance, let's investigate 5-digit fourth powers: We expect to find about eight of them, sqrt(sqrt(99999)) - sqrt(sqrt(10000)) = 7.78, of which only 40% will be candidates to a solution (the ones whose bases end in 2, 4, 6 and 8), that is, about three candidates ( 7.78 * 0.4 = 3.11). In fact, for this case, we have eight powers, 10^4 through 17^4, but only 12^4, 14^4 and 16^4 might be a solution. The probability of an individual digit is equal or greater than five is 0.5 and the probability a five-digit power is a solution is 0.5^5 = 1/32. So, the probability a solution is found among our three candidates is 3/32 or about one chance in eleven. Likewise, if we check all 14-digit fourth powers we'll find the chances are smaller: about one in seventeen. But we've been lucky this time, as we know. ```((sqrt(sqrt(1e15)) - sqrt(sqrt(1e14)))*0.4)/(0.5^-14) = 16.64 ``` Of course, if new properties concerning these powers are discovered, this result should be reconsidered and they might even lead to a different conclusion. Gerson.

 Re: Mini Challenge from comp.sys.hp48Message #17 Posted by Chuck on 28 Mar 2010, 6:56 p.m.,in response to message #16 by Gerson W. Barbosa Definitely a probability problem. 26000000^4 has 30 digits in it. The probability that none are less than 5 is P(none are<5)=0.5^30 =9.3x10^-10, and it only gets worse from there. But again, it's not impossible, but highly unlikely. :) Edited: 28 Mar 2010, 8:55 p.m. after one or more responses were posted

 Re: Mini Challenge from comp.sys.hp48Message #18 Posted by Gerson W. Barbosa on 28 Mar 2010, 7:26 p.m.,in response to message #17 by Chuck Considering there's a lot more squares of squares with 30 digits in them, the overall probability to find a solution in this group is 9.17e-3 or about 1/109 (if the distribution of the digits follows a random order, which is not exactly the case). But you're right, that's still a dim probability and it dwindles as we go further. Edited: 28 Mar 2010, 7:28 p.m.

 Re: Mini Challenge from comp.sys.hp48Message #19 Posted by Han on 29 Mar 2010, 11:16 p.m.,in response to message #17 by Chuck Quote: Definitely a probability problem. 26000000^4 has 30 digits in it. The probability that none are less than 5 is P(none are<5)=0.5^30 =9.3x10^-10, and it only gets worse from there. But again, it's not impossible, but highly unlikely. :) That would only be true if the digits were completely random and independent of the number being raised to the fourth power. However, any number ending in an odd digit has a probability of 1 for having at least one small digit when raised to the power of four. It is certainly true that a RANDOM 30 digit number among all possible 30 digit numbers is unlikely to have no small digit.

 Re: Mini Challenge from comp.sys.hp48Message #20 Posted by PeterP on 28 Mar 2010, 5:41 p.m.,in response to message #1 by Egan Ford Having a couple of hours free today I thought I give it a try with MCODE for the 41. Alas, we don't have enough digits precision (10) in the normal format and I'm too lazy right now to see if 13 digits would be enough (as noone has posted the actual solution number). The below MCODE program tests until X=316 before it crashes out without having found a solution. Is that correct? Maybe I get around to rewriting it for 13 digits but looking at the code, its not trivial and run time wise, this is going to be slow as well. But would be great to know how high the solution number is and if it can be found with 13 digit accuracy at all... For those enjoying MCODE, here is the code: To speed up the expensive part - calculating x^4, I first calculate which power of 2 is smaller than x (and then smaller than x^2) as the NUT can do multiplication by 2 very quickly so that should speed up the power calculation. It also checks for the starting number not ending in 1,3,5,7,9,0. All of them seem obvious, although it took a little while for me to make sure 5 is correct as well. Cheers, Peter ```;============================================================================================= ; X4 - Find a number x who's 4th power has no digit less than 5 ; ; Takes a starting number from x ; moves into a mantissa only format, right justified ; checks that does not end in 1,3,5,7,9,0 ; calcs x^2 ; calcs x^4 ; Checks if any digits <5 ; If no, putputs result to X-reg ; If yes, read x, increase by one, loop ;©pplatzer 2010 ;============================================================================================= .NAME "X4" ;Main Code *0012 0B4 #0B4 ; "4" *0013 018 #018 ; "X" 0014 1A0 [X4] A=B=C=0 ;tabula rasa 0015 2A0 SETDEC ;all calcs in decmode 0016 35C R= 12 ;spot of first digit in C[M] 0017 0F8 READ 3(x) ;get start number 0018 2FA ?C#0 M ;check that not 0 0019 06B JNC [StartW1] +13 0026 ;no -> start with 1 001A 2F6 ?C#0 XS ;check that no negative exponent 001B 05F JC [StartW1] +11 0026 ;no -> start with 1 001C 31C R= 1 001D 2E2 ?C#0 @R ;check that exp < 10 001E 047 JC [StartW1] +8 0026 ;no -> start with 1 001F 05E C=0 MS ;just in case 0020 39C R= 0 0021 2A2 C=-C-1 @R ;complement exponent 0022 262 [RJus] C=C-1 @R ;right justify number 0023 02F JC [RJusD] +5 0028 ;if underflow, we are done 0024 3DA RSHFC M 0025 3EB JNC [RJus] -3 0022 0026 04E [StartW1] C=0 ALL ;invalid start number 0027 23A C=C+1 M ;starting point = 1 0028 046 [RJusD] C=0 S&X ;clean up from shifting loop 0029 27A C=C-1 M ;as [NxtTry] does a C=C+1 first 002A 0E8 WRIT 3(x) ;write start to X 002B 1A0 [NxtTry] A=B=C=0 ;tabula rasa 002C 270 RAMSLCT ;select first ram chip 002D 0F8 READ 3(x) ;read last try # 002E 23A C=C+1 M ;next digit 002F 289003 ?CGO [ERROF] 00A2 0031 0E8 WRIT 3(x) ; 0032 01C [CheckDigs] R= 3 ;check that last dig is not 1,3,5,7,9,0 0033 10E A=C ALL ;save number into A 0034 2E2 ?C#0 @R ;check for 0 0035 3B3 JNC [NxtTry] -10 002B 0036 222 C=C+1 @R ;check for 9 0037 3A7 JC [NxtTry] -12 002B 0038 222 C=C+1 @R 0039 222 C=C+1 @R ;check for 7 003A 38F JC [NxtTry] -15 002B 003B 222 C=C+1 @R 003C 222 C=C+1 @R ;check for 5 003D 377 JC [NxtTry] -18 002B 003E 222 C=C+1 @R 003F 222 C=C+1 @R ;check for 3 0040 35F JC [NxtTry] -21 002B 0041 222 C=C+1 @R 0042 222 C=C+1 @R ;check for 1 0043 347 JC [NxtTry] -24 002B 0044 04E [StartX2] C=0 ALL ;good start number in A 0045 09A B=A M ;save number into B 0046 23A C=C+1 M ;C:= 1 0047 1A6 A=A-1 S&X 0048 070 [Get2Pwr] N=C ;save this power to N 0049 166 A=A+1 S&X ;find which power of 2 < # 004A 1FA C=C+C M ;2, 4, 8, 16, ... 004B 31A ?A out of range 0055 1A6 A=A-1 S&X ;count down n from 2^n 0056 3E3 JNC [DoPwr2] -4 0052 0057 07A [DoRestM] A<>B M ;get # back 0058 21A C=A+C M ;do rest multi 0059 289003 ?CGO [ERROF] 00A2 005B 07A A<>B M 005C 1BA A=A-1 M 005D 3D3 JNC [DoRestM] -6 0057 005E 07A A<>B M ;correct one to many additions 005F 0BA C<>A M 0060 25A C=A-C M ;correct result for x^2 ;------------------------------------ Stepping Stone ----------------------------- 0061 013 JNC [StartX4] +2 0063 0062 24B [NxtTryJP] JNC [NxtTry] -55 002B ;------------------------------------ Stepping Stone ----------------------------- 0063 046 [StartX4] C=0 S&X ;clean up 0064 10E A=C ALL 0065 08E B=A ALL 0066 04E C=0 ALL ;find power of 2 0067 23A C=C+1 M 0068 1A6 A=A-1 S&X 0069 070 [4Get2Pwr] N=C ;save this power to N 006A 166 A=A+1 S&X ;find which power of 2 < # 006B 1FA C=C+C M ;2, 4, 8, 16, ... 006C 31A ?A out of range 0076 1A6 A=A-1 S&X ;count down n from 2^n 0077 3E3 JNC [4DoPwr2] -4 0073 0078 07A [4DoRestM] A<>B M ;get # back 0079 21A C=A+C M ;do rest multi 007A 289003 ?CGO [ERROF] 00A2 007C 07A A<>B M 007D 1BA A=A-1 M 007E 3D3 JNC [4DoRestM] -6 0078 007F 07A A<>B M ;correct one to many additions 0080 0BA C<>A M 0081 25A C=A-C M ;correct result for x^4 0082 00E [CheckR] A=0 ALL ;now check if good result 0083 0AE A<>C ALL ;# into A 0084 130105 LDIS&X 105 ;check for 5 0086 33C RCR 1 ;5 into C[MS] 0087 056 C=0 XS ; 008 into C[S&X] 0088 3EE [ShftNr] LSHFA ALL ;move # into A[MS] 0089 266 C=C-1 S&X 008A 35E ?A#0 MS ;are we there yet? 008B 3EB JNC [ShftNr] -3 0088 008C 31E [TstDig] ?AC S&X 009A 39C R= 0 ;only exp up to 9 possible anyway 009B 2A2 C=-C-1 @R 009C 0E8 WRIT 3(x) 009D 3E0 RTN ```

 Re: Mini Challenge - 45s MCODEMessage #21 Posted by PeterP on 30 Mar 2010, 12:42 p.m.,in response to message #20 by PeterP okay,I'm such a sucker for these things, it is pathetic. But so much fun... Anyway, I could not rest but wanted to see if we can entice the 41 to also spit out an answer in non-geological times. The code below uses all 14 internal digits we have to represent numbers, better multiplication logic and takes advantage of the fact that we can exclude from the interim result x^2 all numbers that start with 1, 4, 5, 6 as they will yield a first number <5. On V41 and normal speed setting (which feels close to a 41cx or maybe a bit faster) it gives us the answer in about 45 seconds. If we remove the tests for X^2 it takes about 1minute. Not bad for the little guy... Cheers Peter ```;============================================================================================= ; X43 - Find a number x who's 4th power has no digit less than 5 ; ; Takes a starting number from x ; uses right justified format in C[S&X & M] ; only uses odd numbers (ending in ) 2,4,6,8 (as 0,1,3,5,7,9 are out). ; calcs x^2 ; Exclude x^2 that start in 1,4,5,6 ; calcs x^4 ; Checks if any digits <5 ; If no, outputs result to X-reg ; If yes, read x, increase by two, loop ;©pplatzer 2010 ;============================================================================================= .NAME "X43" ;Main Code *0103 0B3 #0B3 ; "3" *0104 034 #034 ; "4" *0105 018 #018 ; "X" 0106 1A0 [X43] A=B=C=0 ;tabula rasa 0107 2A0 SETDEC ;all calcs in decmode 0108 35C R= 12 ;spot of first digit in C[M] 0109 0F8 READ 3(x) ;get start number 010A 2FA ?C#0 M ;check that not 0 010B 06B JNC [StartW23] +13 0118 ;no -> start with 2 010C 2F6 ?C#0 XS ;check that no negative exponent 010D 05F JC [StartW23] +11 0118 ;no -> start with 2 010E 31C R= 1 010F 2E2 ?C#0 @R ;check that exp < 10 0110 047 JC [StartW23] +8 0118 ;no -> start with 2 0111 05E C=0 MS ;just in case 0112 39C R= 0 0113 2A2 C=-C-1 @R ;complement exponent 0114 262 [RJus3] C=C-1 @R ;right justify number 0115 037 JC [RJusD3] +6 011B ;if underflow, we are done 0116 3DA RSHFC M 0117 3EB JNC [RJus3] -3 0114 0118 04E [StartW23] C=0 ALL ;invalid start number 0119 23A C=C+1 M ;starting point = 2 011A 23A C=C+1 M ;starting point = 2 011B 046 [RJusD3] C=0 S&X ;clean up from shifting loop 011C 03C RCR 3 ;now check that even number 011D 3D8 C<>ST ;shift C[01] into flags 011E 38C ?FSET 0 ;odd number? 011F 027 JC [OddNr3] +4 0123 0120 3D8 C<>ST ;bring back the number 0121 26E C=C-1 ALL ;as [NxtTry] does 2x C=C+1 first 0122 013 JNC (conEv3) +2 0124 0123 3D8 [OddNr3] C<>ST ;bring back the number 0124 26E (conEv3) C=C-1 ALL ;as [NxtTry] does 2x C=C+1 first 0125 0E8 WRIT 3(x) ;write start to X 0126 1A0 [NxtTry3] A=B=C=0 ;tabula rasa 0127 270 RAMSLCT ;select first ram chip 0128 0F8 READ 3(x) ;read last try # 0129 22E C=C+1 ALL ;next even number 012A 22E C=C+1 ALL 012B 0E8 WRIT 3(x) ; 012C 39C [Check03] R= 0 ;check if it ends in 0 012D 2E2 ?C#0 @R ;is last digit <> 0 012E 3C3 JNC [NxtTry3] -8 0126 ;no -> get next number 012F 00E [StartX23] A=0 ALL ;Clean A (accumulator for multi) 0130 0EE0CE B=C ALL ;put number into B as well 0132 2DC R= 13 ;C[MS] 0133 3D4 [MLoop3] R=R-1 ;move pointer 0134 2D4 ?R= 13 ;are we done? 0135 037 JC [DoneX23] +6 013B ;Yes, we have done all digits 0136 3EE LSHFA ALL ;=x10 0137 262 [MCnt3] C=C-1 @R ;count down digits of number in C 0138 3DF JC [MLoop3] -5 0133 ;if 0, no multiplication 0139 12E A=A+B ALL ;if <>0, do multiplication 013A 3EB JNC [MCnt3] -3 0137 013B 08E [DoneX23] B=A ALL ;result into B 013C 0CE C=B ALL ;result into C 013D 00E A=0 ALL ;clear A 013E 2DC R= 13 ;check if we have a start in 1,4,5,6 013F 3D4 [Fnd1stX2] R=R-1 ;find first dig 0140 2E2 ?C#0 @R ;is this the first dig? 0141 3F3 JNC [Fnd1stX2] -2 013F ;no, keep looking 0142 262 C=C-1 @R ;Check for 1 0143 2E2 ?C#0 @R ; 0144 313 JNC [NxtTry3] -30 0126 0145 262 C=C-1 @R 0146 262 C=C-1 @R 0147 262 C=C-1 @R ;Check for 4 0148 2E2 ?C#0 @R ; 0149 2EB JNC [NxtTry3] -35 0126 014A 262 C=C-1 @R ;Check for 5 014B 2E2 ?C#0 @R ; 014C 2D3 JNC [NxtTry3] -38 0126 014D 262 C=C-1 @R ;Check for 6 014E 2E2 ?C#0 @R ; 014F 2BB JNC [NxtTry3] -41 0126 0150 0CE C=B ALL ;all good, do X^4 0151 2DC R= 13 ;prep for next multi 0152 3D4 [MLoop23] R=R-1 ;move pointer 0153 2D4 ?R= 13 ;are we done? 0154 037 JC [DoneX43] +6 015A ;yes, we have done all digits 0155 3EE LSHFA ALL 0156 262 [MCnt23] C=C-1 @R 0157 3DF JC [MLoop23] -5 0152 0158 12E A=A+B ALL 0159 3EB JNC [MCnt23] -3 0156 015A 00B [DoneX43] JNC [CheckR3] +1 015B ;result in A:= x^4 015B 04E [CheckR3] C=0 ALL ;now check if good result 015C 130135 LDIS&X 135 ;check for 5 & counter for 13 digits 015E 33C RCR 1 ;5 into C[MS] 015F 01B JNC [Chk1st3] +3 0162 0160 3EE [ShftNr3] LSHFA ALL ;move # into A[MS] 0161 266 C=C-1 S&X 0162 35E [Chk1st3] ?A#0 MS ;are we there yet? 0163 3EB JNC [ShftNr3] -3 0160 0164 31E [TstDig3] ?AC S&X 0173 39C R= 0 ;only exp up to 9 possible anyway 0174 2A2 C=-C-1 @R 0175 0E8 WRIT 3(x) 0176 3E0 RTN ```

 Re: Mini Challenge - 45s MCODEMessage #22 Posted by Egan Ford on 30 Mar 2010, 4:47 p.m.,in response to message #21 by PeterP Nice! I've been so swamped I have been unable to work out any solution except for a small python script because I wanted to see the answer: ```import re; ``` ```i=0; while(1): i+=2; if not i % 10: next; if not re.search("[0-4]",str(i**4)): print i, i**4; break; ```

Go back to the main exhibit hall