Convert integers from base 10 to proper primary notation - MATLAB Cody - MATLAB Central

Problem 60783. Convert integers from base 10 to proper primary notation

Difficulty:Rate
This problem is the companion to Cody Problem 60782. The proper primary system of expressing non-negative numbers has three digits: m, x, and p, which correspond to -1, 0, and 1. The places in a proper primary number correspond to the prime numbers. For example, the number 6 would be ppm in proper primary notation because . Similarly, the number 20 would be ppxxp in proper primary notation.
Because integers can be expressed as sums (and differences) of primes in several ways, several primary notations for a non-negative number can exist. However, numbers in proper primary notation adhere to the following requirement: when m, x, and p are replaced with 0, 1, and 2, respectively, the resulting decimal number is minimal.
For instance, 5 can be represented as pp, pxx, and pxmm; since 22 is smaller than 211 or 2100, pp is the proper primary representation of 5. The number 12 can be represented as pxpp and ppxx; since 2122 is less than 2211, pxpp is the proper primary representation of 12. The number -15 can be represented as mmmx and mmxpx; since 1 is less than 121, mmmx is the proper primary representation of -15.
Write a function to convert non-negative integers in base 10 to proper primary notation.

Solution Stats

100.0% Correct | 0.0% Incorrect
Last Solution submitted on Jan 09, 2025

Problem Comments

Solution Comments

Show comments
R2025a Pre-release highlights
This topic is for discussing highlights to the current R2025a Pre-release.
18
8

Problem Recent Solvers3

Suggested Problems

More from this Author291

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page