Consider using a small tolerance for the solution. My program coincides with your test cases up to 3e-16. That ought to be good enough, I think :)
My solution error was at 2.22e-16. Still not good enough, though.
Obviously round(A\b) is the alledgedly correct answer which is in general different from the numerical approximation of the solution.
I wonder whether this is intended?
Assumes the solutions are always integers. The tests would ideally use a tolerance in checking the solutions.
Find the peak 3n+1 sequence value
1122 Solvers
Project Euler: Problem 7, Nth prime
539 Solvers
Find out missing number from a vector of 9 elements
247 Solvers
499 Solvers
341 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!