Given an array, n, of positive integers, return an array, c, of the same size, in which each element is the complexity of the corresponding element in n.
Integer complexity is defined in number theory as the least number of ones required to represent an integer using only addition, multiplication and parentheses.
Example 1:
n = 3
c = 3
Example 2:
n = [6 10 11;16 18 41]
c = [5 7 8;8 8 12]
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers23
Suggested Problems
-
Remove any row in which a NaN appears
8768 Solvers
-
2176 Solvers
-
Change the sign of even index entries of the reversed vector
638 Solvers
-
775 Solvers
-
5874 Solvers
More from this Author45
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!