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.
Maximum running product for a string of numbers
Project Euler: Problem 6, Natural numbers, squares and sums.
Sum of first n terms of a harmonic progression
We love vectorized solutions. Problem 1 : remove the row average.
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office