Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7598207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:21:05+00:00 2026-05-30T22:21:05+00:00

Well, this is another question taken from this practice exam that was given to

  • 0

Well, this is another question taken from this practice exam that was given to me that I just don’t know what to do with.

int fun5 (int c, int d) {
    if (c <= d) {
        return c;
    } else {
        return fun5(c-d, d) * c;
    }
}

When you run the code with value of fun5(9,3), you’re supposed to get 162, but I have not idea how to get there. Obviously the first if statement is false, so you go to the else, but then you have to go back to fun5 with those new values, but then the if statement fails again, so you go to the else again, but you just came from there. I’m just a very confused person right now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:21:07+00:00Added an answer on May 30, 2026 at 10:21 pm

    It’s recursion

    The first time c=9 and d=3 so you do the else statement: (below with the numbers substituted)

    return fun5(9-3, 3) * 9;
    

    Then you do the next go with c=6 and d=3 so you do the else again

    return fun5(6-3, 3) * 6;
    

    Then you do the next one with c=3 and d=3 so you do the if

    return 3;
    

    Follow it up the stack you get

    return 3;
    return 3 * 6;
    return 18 * 9;
    

    Final return is 18 * 9 or 162.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok another WPF question, well I guess this is just general .NET. I have
Well this is incredibly frustrating. After being nagged by Rails that I need to
I hope I can explain this well enough so that you can understand the
I have previously read Spolsky's article on character-encoding, as well as this from dive
Well I have this MySQL stored procedure that I wrote and if I run
I know this is more heavy question, but I think its interesting too. It
This question is related to another question I asked. In my other question I
Well, here I am again with another frustrating question. I need to end my
well this is my problem i use 2 source first query (select * from
Well I think I know the answer to this, but I would appreciate anybody

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.