Problem 44341. Hexagonal numbers on a spiral matrix
Solution Stats
Problem Comments
Solution Comments
-
4 Comments
I am not able to figure out why the solutions of my code to test 8 and 9 are wrong.
My wrong results:
- test 8 -> '1250000041666667776'
- test 9 -> '13107200170666672128'
I get precisely the same results as Angelo...
Angelo and Heiko, your solutions are working to a degree. However to obtain exact results on big numbers you have to use different tools. You can search for uint64 and bigdecimal. Hope it helps.
Thanks for the tip with uint64.
-
2 Comments
First line is adopted from James's solution: https://www.mathworks.com/matlabcentral/cody/problems/2455-diagonal-of-a-spiral-matrix/solutions/1239477
I was just happy I could use "diag" and "spiral" in this problem, but it's always nice to see some of my solutions get used in other code.
Problem Recent Solvers98
Suggested Problems
-
1502 Solvers
-
Sum all integers from 1 to 2^n
11064 Solvers
-
Make a run-length companion vector
585 Solvers
-
Back to basics - mean of corner elements of a matrix
331 Solvers
-
There are 10 types of people in the world
619 Solvers
More from this Author76
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!