37
2
Given a natural number n
, return the n
-th Leyland number.
Leyland Number
Leyland numbers are positive integers k
of the form
k = x^y + y^x
Where x,y
are integers strictly greater than 1.
They are enumerated in ascending order.
EDIT: @DigitalTrauma suggested I include following "definition":
Imagine we throw
x^y+y^x
in a bag for all possible values ofx
andy
, and avoid throwing in duplicates. Then we sort that bag. The sorted bag is our sequence.
Details
You may use 0 or 1 based indexing, whatever suits you best.
Your program must be able to output at least all Leyland numbers less than the maximum of signed 32-bit integers. (The last Leyland number below this limit is 1996813914
, at index 82
.)
Test cases
The first few terms are following:
8, 17, 32, 54, 57, 100, 145, 177, 320, 368, 512, 593, 945, 1124
A076980 in OEIS, except for the first entry. Note that because of that additional first entry, the indices on OEIS are shifted by one.
More can be found in the OEIS b-file
They are enumerated in ascending order
I'm not really sure what this means. Could you provide a list of x and y? – James – 2016-06-15T13:26:26.233@DrGreenEggsandIronMan That means,
8
is before17
, not the other way round. – Leaky Nun – 2016-06-15T13:29:21.743@DrGreenEggsandIronMan I think it's
2^2+2^2=8
;2^3+3^2=17
;2^4+4^2=32
;2^5+5^2=57
;2^6+6^2=100
;3^4+4^3=145
<- Note that3^4+4^3
(=145
) is lower than2^7+7^2
(=177
). So basically all possible combinations ofx^y+y^x
sorted from lowest to highest smaller than1996813914
. – Kevin Cruijssen – 2016-06-15T13:31:04.8073@DrGreenEggsandIronMan Imagine we throw
x^y+y^x
in a bag for all possible values ofx
andy
, and avoid thrwoing in duplicates. Then we sort that bag. The sorted bag is our sequence. – flawr – 2016-06-15T13:42:14.977Regarding the 2^32 requirement, does that apply to time or memory considerations? Is it acceptable if the program works I'm theory with unlimited time and memory? – Luis Mendo – 2016-06-15T13:52:37.410
No, it should work on your computer and terminate within a reasonable time. – flawr – 2016-06-15T14:02:33.113
@flawr I think this comment makes it a lot clearer. Can you edit this into the question?
– Digital Trauma – 2016-06-15T16:27:15.38310Very large bag you have there – Luis Mendo – 2016-06-15T18:35:27.563
2@LuisMendo Ask @HenriLéonLebesgue and he is going to tell you that this bag is basically nothing. – flawr – 2016-06-15T18:58:58.280
@flawr Its contained volume is also probably in the neighborhood of -1/12. – Draco18s no longer trusts SE – 2019-01-09T04:34:35.107