+ 25
[🏆 Challenge 🏆] : Leyland numbers 🔢🏆🚨⚠💡🎮
A Leyland number is a number which can be expressed as x^y + y^x. (here ^ stands for exponentiation). Also, both x and y need to be more than 1. Create a program that inputs a number and checks if it is Leyland or not and if it is then prints those 2 numbers also.
29 odpowiedzi
+ 27
//here is my try ☺
⬜🌹🌹🌹🌹🌹⬜
🌹⬜⬜⬜⬜⬜⬜
🌹⬜⬜⬜⬜⬜⬜
🌹⬜⬜⬜🌹🌹🌹
🌹⬜⬜⬜⬜⬜🌹
🌹⬜⬜⬜⬜⬜🌹
⬜🌹🌹🌹🌹🌹⬜
https://code.sololearn.com/cOAPoAQo1v1F/?ref=app
+ 21
yes ... can be equal to y
+ 19
+ 14
https://code.sololearn.com/cwT8AScmsXX7/?ref=app
+ 10
@Ga Yes. Natural numbers
+ 9
@Yash Thatte nice but, both x and y need to be greater than 1 so 2 is not Leyland.
+ 8
@Gaurav Yes
+ 8
Here's my solution in c++:
https://code.sololearn.com/c1IqSCBq9NaA/#cpp
+ 8
@Kazi your code does not accept all Leyland numbers. Eg-100
+ 6
Can x be equal to y?
I know it shouldn't be but if u express it mathematically then this should also be mentioned....
+ 6
here my code..
https://code.sololearn.com/cOd8LnRqFREd/?ref=app
+ 5
@Shashank you have by mistake included #include <iostream> into your comment so your code gives error. Otherwise your code is correct.
+ 5
Here is my solution. Basically brute force, but with smart limits set on the search space. [In particular, the largest that x or y can be is log2(N). And for a given x, you can stop looping over y values once x^y+y^x>N.] Works for any N up to at least 10^18 without timeout.
https://code.sololearn.com/c3h3Kg4pyn8w/?ref=app
+ 4
@Swapnil my try is right?
https://code.sololearn.com/cX73MKe2AUUW/?ref=app
+ 4
Here is my solution. Assuming that x can be equal to y. The real challenge is handling large numbers.
https://code.sololearn.com/Wc818G695mQ1/?ref=app
And since it would be boring if you input a wrong number, here is another one.
https://code.sololearn.com/WGBx5MsI4zBt/?ref=app
And if you do want to see more, try this one. Though you would have to wait.
https://code.sololearn.com/Wy9APGl5xICj/?ref=app
+ 4
problem solved..@Swapnil
+ 4
https://code.sololearn.com/cdReYb0TnnFq/?ref=app
here's my try