So I was a bit bored this morning and pic related is the result.
It has got me interested though, what are some numbers with significance?
>>7738835
just curious, did you get any other pairs out of this run? I noticed this few months ago but gave up on it pretty fast, realizing that there aren't many (if any at all) other pairs that do that)
That's sum fucking retarded code son
>>7738835
Its called functional prgramming for a reason op
print [str(b)+"^"+str(a) for a in range(1,1000)for b in range(a) if a**b == b**a]
#include <stdio.h>
#include <math.h>
int main(void)
{
long long int a, b, ab, ba;
for(a = 1; a < 1000; ++a) {
b = 1;
for(; b < 1000; ++b) {
ba = pow(b,a);
ab = pow(a,b);
if(a!=b)
if(ab==ba) {
printf("%d ^ %d = %d\n", a, b, ab);
printf("%d ^ %d = %d\n\n", b, a, ba);
}
}
}
}
This shit works for 4^2 and 2^4 but after 7 ^ 512 it shits itself and says everything = 0.
Is this an overflow or what? Anyone knows how to fix it?
>>7738938
I'm guessing you don't work with python often.
>>7738835
A guy in my department's 6 year old son thought of the number 2 being the only positive integer like this as well without running a script to figure that out
Basically, you're as smart as a 6 year old.
>>7739017
What the fuck is that else b+=1 clause for? b is going to get reset to the next value in range(a) anyway.
>>7739036
I know. I was saying (in a very unclear way) "this is a typical python program"
>>7739050
You didn't have to do that though.
>>7739012
Use big integer
I read that trivial solutions a=b and (2,4)/(4,2) are the only solutions. It can be proven but I'm not good at that shit.
>>7738835
x^y=y^x
x/y=ln(x)/ln(y)
ln(x)/x=ln(y)/y
The max is at x=e and is strictly decreasing afterwards therefore only x=2 and some y can be the answer. y=3 doesn't work, y=4 does, y=5 is too small proving all y>5 won't work either.
>>7739019
:) fuck yeah.
>>7739019
Also works for 0 and 1
>>7739631
Kek
1^0=0^1
1=0
You=<3
>>7739693
There are many other pairs, so you know. Your code uses exclusive upper bounds on its iterators so you miss the pairs (x,x).
>>7739717
Well those "pairs" aren't very interesting. We know that 3 ^ 3 = 3 ^ 3
>>7739693
Probably a better version:
Flag =True
for a in range(10001):
if Flag:
Flag = False
continue
for b in range(a+1):
if a**b==b**a:
print "Found a match: %d^%d=%d" % (a, b, a**b)
I assume you increment a in the highest loop so that you can exclude 0 (maybe you just did it on accident?) but a Boolean flag paired with a continue statement also acheives this. There are ~~9999 fewer calculations this way.
Also, there's no need for the else statement in the inner loop. Its effect is nullified once the loop re-runs.
I think you're confusing for and while loops. If you had replaced the for loop lines with
while a <= 10000:
And
while b <= a:
Then your code would have made sense.
Don't be the CS meme. Please don't.
>>7739730
Since when are they not interesting?
0^0=0^0 isn't very trivial, you know.
>>7738835
>a+=1
>not a++
>even being there
>else: b+=1
>>7739735
>Then your code would have made sense.
It would have infinite looped on the first working pair
>Don't be the CS meme. Please don't.
It's not a meme, it's reality.
>>7739036
b+ ** a = </ a ** -/+ B
>>7739065
Python and Ruby are the most autistic "coding" languages you'll see that isn't C++/CLI.
>>7738835
I don't know what this language is, so maybe it makes sense, but what I'm thinking is:
Why is that "for b in range (a)" there? If this language has any kind of clarity this would mean "for each element in the range of another element" where the other element is a single integer. What the fuck could that mean?
Why are you incrementing "a" every loop?
Why are you incrementing "b: at the end even though it will fall out of scope by the end of the loop?
What exactly is that code finding?
>>7739843
welcome to python my friend :^) the syntax is very unclear imo but what do I know, I just know java
>>7739843
>"for each element in the range of another element" where the other element is a single integer.
range(a) generates a list of integes f.e. range(10) gives [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], now you iterate over these elements ( for (each element) in (this list)
>Why are you incrementing "a" every loop?
its retarded and he shouldnt
>Why are you incrementing "b: at the end even though it will fall out of scope by the end of the loop?
see a
>>7739764
I meant if he changed it in his original code, not in the code I gave him. So he would change the first bit of his to
a=0
while a < 10000:
a+=1
... And so on
>>7739012
https://gmplib.org/
or some other arbitrary precision library
>>7738835
Nice to see some python coding in ST :)
Obvs you are using the syntax highlighting but what color scheme is that?
>>7738835
Thank you for this contribution to computational number theory.
>>7741026
Compatibility issues.
>>7740555
I'm not sure but it is one of the default atom schemes