1. Engineering
  2. Computer Science
  3. 2 write a function that converts a natural number nonnegative...

Question: 2 write a function that converts a natural number nonnegative...

Question details

2. Write a function that converts a natural number (nonnegative integer) into an array of its decimal digits. It should have the signature function X = unt-to-digits(x) where x is a natural number and X is an array of natural numbers between 0 and 9. For example, uint.to.digits (12345) outputs ans = 1 2 3 45 Hint: The commands log10 and floor (or ceil) are useful.) Show the results for uint.to_digits (2 53) uint to_digits (2 53 1) uint_to_digits (253 + 2) Explain why two of the three outputs are equal.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution