Question
This is the synopsis of the program: Octonumero (ver 2) An octonumero of a number x is found as follows. Convert x to base 8,
This is the synopsis of the program:
Octonumero (ver 2)
An octonumero of a number x is found as follows.
- Convert x to base 8, call this p
- Sort the digits of p in increasing order, call this q
- Subtract q from p in octal (convert q and p to decimal, subtract and convert back to octal)
- Repeat steps 2 - 3, four more times or until the digits in the result are in sorted order.
- Convert the number back to decimal
Example:
x = 341810
convert: 341810 = 65328
sort and subtract: 65328 - 23568 = 41548
4 more times: 41548 - 14458 = 25078
3 more times: 25078 - 2578 = 2230,
2 more times: 22308 - 2238 = 20058
last time: 20058 - 258 = 17608
convert: 17608 = 100810
How do I do these methods:
- public static int arrayToNum ( int[] arr )
arrayToNumreturns the elements as one number such that each element becomes a digit of the returned value. The element atarr.length - 1is the ones digits
- public static int octalSubtract (int larger, int smaller)
octalSubtractwill return the difference between larger and smaller in base 8
Can you please send me the code, as I learn better like that than the sentence explanations please? Thanks again for your time :D
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started