Write a program that uses a recursive call to find the integer logb of a number. Where logb returns the integer log of a number in a designated base. For example, the integer base 10 log of 1234 is 3, and the integer base 2 log of 1234 is 10. This is a relatively easy calculation. You simply repeatedly divide the number by the base using integer division until the quotient is less than the base and count the number of completed divisions. 1234/10 123 (1) 123/10 12 (2) 12/101 (3) 1234/2= 617 (1) 617/2 308 (2) 308/2 154 (3) 154/2 77 (4) 77/2 = 38 (5) 38/2 = 19 (6) 19/2=9 (7) 9/2=4 (8) 4/2=2 (9) 2/2 = 1 (10) Notice that the number 1234 is actually 1 x 10^3 + 2 x 10^2 + 3x10^1 + 4 x 10^0 and in base 2 the number 1234 would be 1 x 2^10 + 0 x 2^9 + 0 x 2^8 + 1 x 2^7 +1 x 2^6 +0x2^5 + 1 x 2^4 + 0 x 2^3 + 0x 2^2 + 1 x 2^1 + 0x2^0 The key point here is that the highest power value, in each of these number representations, is the integer log value. Hint use the number and the base as arguments to your recursive call, then your base case is when number is less than base and returns 0, and the general case returns 1 plus the returned value of the recursive call.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help creating a java code program that shows like this

Your program should behave as follows.

Please enter a number to find the integer log of
1234
Please enter the base for the calculation
2
The base 2 integer log of 1234 is 10
Would you like to enter another pair of numbers?
Please enter "y" for yes or "n" for no.
b
Please enter "y" for yes or "n" for no.
y
Please enter a number to find the integer log of
1234
Please enter the base for the calculation
5
The base 5 integer log of 1234 is 4
Would you like to enter another pair of numbers?
Please enter "y" for yes or "n" for no.
n
Good-bye!

 

 

Problem is Shown in image below:

Write a program that uses a recursive call to find the integer logb of a number. Where logb returns the integer log of a number in a
designated base. For example, the integer base 10 log of 1234 is 3, and the integer base 2 log of 1234 is 10. This is a relatively
easy calculation. You simply repeatedly divide the number by the base using integer division until the quotient is less than the
base and count the number of completed divisions.
1234 / 10 123 (1)
123/10 12 (2)
12/101 (3)
1234/2 617 (1)
617/2 308 (2)
308/2 = 154 (3)
154/2 77 (4)
77/2 = 38 (5)
38/2 = 19 (6)
19/2 = 9 (7)
9/2=4 (8)
4/2=2 (9)
2/2 = 1 (10)
Notice that the number 1234 is actually 1 x 10^3 + 2 x 10^2 + 3 x10^1 + 4 x 10^O
and in base 2 the number 1234 would be 1 x 2^10 + 0 x 2^9 + 0x2^8 + 1 x 2^7 +1 x 2^6 + 0x2^5 + 1 x 2^4 + 0x2^3 + 0x
2^2 + 1 x 2^1 + 0 x 2^0
The key point here is that the highest power value, in each of these number representations, is the integer log value.
Hint use the number and the base as arguments to your recursive call, then your base case is when number is less than base and
returns 0, and the general case returns 1 plus the returned value of the recursive call.
Transcribed Image Text:Write a program that uses a recursive call to find the integer logb of a number. Where logb returns the integer log of a number in a designated base. For example, the integer base 10 log of 1234 is 3, and the integer base 2 log of 1234 is 10. This is a relatively easy calculation. You simply repeatedly divide the number by the base using integer division until the quotient is less than the base and count the number of completed divisions. 1234 / 10 123 (1) 123/10 12 (2) 12/101 (3) 1234/2 617 (1) 617/2 308 (2) 308/2 = 154 (3) 154/2 77 (4) 77/2 = 38 (5) 38/2 = 19 (6) 19/2 = 9 (7) 9/2=4 (8) 4/2=2 (9) 2/2 = 1 (10) Notice that the number 1234 is actually 1 x 10^3 + 2 x 10^2 + 3 x10^1 + 4 x 10^O and in base 2 the number 1234 would be 1 x 2^10 + 0 x 2^9 + 0x2^8 + 1 x 2^7 +1 x 2^6 + 0x2^5 + 1 x 2^4 + 0x2^3 + 0x 2^2 + 1 x 2^1 + 0 x 2^0 The key point here is that the highest power value, in each of these number representations, is the integer log value. Hint use the number and the base as arguments to your recursive call, then your base case is when number is less than base and returns 0, and the general case returns 1 plus the returned value of the recursive call.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Fibonacci algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education