mersenneforum.org Find unique 4-digit number abcd=a^b*c^d
 Register FAQ Search Today's Posts Mark Forums Read

 2023-09-16, 05:42 #12 Batalov     "Serge" Mar 2008 San Diego, Calif. 2×3×1,733 Posts That was a good one! Meanwhile, In Soviet Russia, 1 is defined as 0^0 by Supreme Leader. In Soviet Russia, no one knows the truth before Putin blurts a few words on the subject. Then it becomes the truth and everyone is required by law to repeat it. Those who don't get 10, 15, 25 years in prison.
 2023-09-16, 05:45 #13 LaurV Romulan Interpreter     "name field" Jun 2011 Thailand 2×5,179 Posts Leading zeros don't count.
 2023-09-16, 10:56 #14 retina Undefined     "The unspeakable one" Jun 2006 My evil lair 23·857 Posts For those that don't like using 00, here is a solution for a longer version: Code: r=range(10) for a in r: for b in r: for c in r: for d in r: for e in r: for f in r: if a*100000+b*10000+c*1000+d*100+e*10+f==a**b+c**d+e**f:print(a,b,c,d,e,f) Outputs Code: 0 0 0 0 0 2 0 1 7 5 3 6 The first answer relies upon 00 being defined, but the second answer doesn't.
2023-09-16, 14:39   #15
Dr Sardonicus

Feb 2017
Nowhere

650910 Posts

Quote:
 Originally Posted by retina For those that don't like using 00, here is a solution for a longer version: Code: r=range(10) for a in r: for b in r: for c in r: for d in r: for e in r: for f in r: if a*100000+b*10000+c*1000+d*100+e*10+f==a**b+c**d+e**f:print(a,b,c,d,e,f) Outputs Code: 0 0 0 0 0 2 0 1 7 5 3 6 The first answer relies upon 00 being defined, but the second answer doesn't.
Purportedly n-digit numbers with leading zeroes are phony baloney.

Your additive problem has no solutions with more than 10 digits, because k*9^9 < 10^(2*k - 1) for k > 5.

2023-09-16, 21:59   #16
uau

Jan 2017

101011102 Posts

Quote:
 Originally Posted by Dr Sardonicus Purportedly n-digit numbers with leading zeroes are phony baloney. Your additive problem has no solutions with more than 10 digits, because k*9^9 < 10^(2*k - 1) for k > 5.
I checked that it has no 8 or 10 digit solutions without at least two leading zeroes.

 2023-09-16, 22:37 #17 uau   Jan 2017 2·3·29 Posts I also checked for 10 digit sums with close misses - closest was 40357946 (that's 8 digits with an error of 1, found as 10 digits with an error of 2, with one more from an extra +0^0).
2023-09-16, 23:50   #18
HermannSW

"H. Stamm-Wilbrandt"
Jul 2023
Eberbach/Germany

22·11 Posts

Back to original problem:
Quote:
 Originally Posted by HermannSW Here is the 75 character version, no guarantee that it is shortest possible (thanks, I learned about "spoiler" tag from you): Code: ? forvec(v=vector(4,x,[0,9]),if(fromdigits(v)==v[1]^v[2]*v[3]^v[4],print(v))) [2, 5, 9, 2] ?
"fromdigits()" is just too long.
Instead of forvec use for loop.
And convert number with "digits()" and multi assign.
Result is 60 character PARI/GP one-liner:
Code:
\$ gp -q
? for(i=1000,9999,[a,b,c,d]=digits(i);if(a^b*c^d==i,print(i)))
2592
?
40 years ago at school where I learned about this puzzle, I lived in German town with dialing code 02592 ...

2023-09-17, 03:12   #19
Batalov

"Serge"
Mar 2008
San Diego, Calif.

1039810 Posts

Quote:
 Originally Posted by HermannSW "fromdigits()" is just too long. Instead of forvec use for loop. And convert number with "digits()" and multi assign.
Premature optimization is the $\sqrt {all \ evil}$

 2023-09-17, 12:48 #20 HermannSW     "H. Stamm-Wilbrandt" Jul 2023 Eberbach/Germany 22×11 Posts While I agree with you in general, I don't see how your statement applies to my previous post. Only smartphone with me currently, but PariDroid runtime reported is 0ms, see attachment. Attached Thumbnails

 Similar Threads Thread Thread Starter Forum Replies Last Post sweety439 sweety439 0 2020-02-11 03:12 Retep Riesel Prime Search 8 2013-10-31 11:35 RedGolpe Factoring 4 2007-03-23 15:24 Unregistered Math 11 2004-11-30 22:53 Unregistered Software 3 2004-03-03 19:20

All times are UTC. The time now is 10:47.

Sun Sep 24 10:47:43 UTC 2023 up 11 days, 8:30, 0 users, load averages: 1.04, 1.14, 1.00