This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Recursion

 
Ranch Hand
Posts: 332
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to make sure I got these questions correct.
For:
6a) 2
6b)6
6c)18
question.PNG
[Thumbnail for question.PNG]
 
Marshal
Posts: 7271
492
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Didn't check other answers, but [a] seems to be incorrect to me.
[edit] I'm not longer sure. Wait.

Can you explain how you derived to such answer for [a]?
 
Marshal
Posts: 14373
240
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to explain how you came to each of those answers.

And c) actually has two questions but you only gave one answer.

And the question is #7, so 7a, 7b, and 7c.
 
Master Rancher
Posts: 3399
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
None of your answers are correct, unfortunately.  Your answer to a is too small, and the answers for b and c are too big.  (For either answer to c.)  I suggest writing the code and modifying it to count how many times it multiplies.  Maybe even print each time the pow() method is called.
 
Ana Smith
Ranch Hand
Posts: 332
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:Didn't check other answers, but [a] seems to be incorrect to me.
[edit] I'm not longer sure. Wait.

Can you explain how you derived to such answer for [a]?


How would you go about answering these questions? I also believe my work is wrong for the first question.
pic.jpg
[Thumbnail for pic.jpg]
 
Junilu Lacar
Marshal
Posts: 14373
240
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Simmons has a very good suggestion. I encourage you to try it.
 
Liutauras Vilda
Marshal
Posts: 7271
492
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mike Simmons wrote:I suggest writing the code and modifying it to count how many times it multiplies.  Maybe even print each time the pow() method is called.


Do you really need to print each time pow() is called? That would give an incorrect impression I think. Multiplication happens only in the else clause and the result of multiplication is the y within the same else clause.
 
Bartender
Posts: 3611
151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike doesn't claim that the two are equal. It is just that printing both values might give you an idea how the two are related, maybe giving a clue how to prove that relationship.
 
Liutauras Vilda
Marshal
Posts: 7271
492
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:Mike doesn't claim that the two are equal. It is just that printing both values might give you an idea how the two are related, maybe giving a clue how to prove that relationship.


I have worded it slightly imprecise. Just wanted to raise some question publicly so OP wouldn't decide blindly to follow advice and submit that as an answer.
 
Piet Souris
Bartender
Posts: 3611
151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand.

Yesterday evening, I wanted to propose the same thing as Mike did, had even written the code for it (including your comment) but just before I wanted to submit, I saw that Mike had already replied. And I realised his reply was far better than mine: he left that problem for OP to discover and solve.
 
Liutauras Vilda
Marshal
Posts: 7271
492
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Piet Souris wrote:...Mike... ...he left that problem for OP to discover and solve.


Situation handling mastery. So OP it seems has more than enough information to solve this problem. I'm sorry that I spoiled this exercise too much   .
 
Mike Simmons
Master Rancher
Posts: 3399
33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will pretend that I meant to word it carelessly, as an exercise for the reader.  Yes, that's the ticket.
 
Get out of my mind! Look! A tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!