According to Fermat’s Last Theorem, no three positive integers a, b, c satisfy the equation, a^n + b^n = c^n for any integer value of n greater than 2. For n = 1 and n = 2, the equation have infinitely many solutions.
function fermat_last(limit, n) { if(n < 3) return; for(var a = 1; a <= limit; a++) for(b = a; b <= limit; b++) { var pow_sum = parseInt(power(a, n)) + parseInt(power(b, n)); var c = parseInt(power(pow_sum, parseInt(1.0/n))); var c_pow = parseInt(power(c, n)); if(c_pow === pow_sum) { return "Count example found"; } } return "No counter example within given range and data"; }