There are many numbers which can be expressed as the difference of two squares, or as the difference of two cubes, or maybe even higher powers. Talking about squares, there are various ways of writing a number, say 75, as the difference of 2 squares. You can write:
75 = (10)^2 - (5)^2 = (14)^2 - (11)^2 = (38)^2 - (37)^2
So let's talk about the challenge. Firstly, the user enters a number and then he enters a value for n. You need to display all the ways in which that number can be written in the form of aⁿ - bⁿ.
Input and Output
The input will be the number and the value of n. Your output shall have all such pairs of 'a' and 'b' such that the above-stated condition is met. The first number in the pair must be larger than the second. Please note that a, b, n and the input number are all positive integers, and n > 1.
50, 2 -> (none) 32, 2 -> (9,7), (6, 2) 7, 3 -> (2,1) 665, 6 -> (3, 2) 81, 4 -> (none)
This is code-golf , so the shortest code wins!