0

My recursive function multiplies the given area by 1.5 until it reaches 100,000. The output is supposed to be how many times it had to multiply by 1.5. I think I understand most of what I need to do, but I'm not sure what to put in my (if) statement.

(define area-multiplier
  (lambda (area)
    (if (< 100000 area)
        0         ;what do I put here?
        (+ 1 (area-multiplier (* area 1.5))))))

2 Answers 2

1

Think about this using an example. In this case, the relevant examples are

(area-multiplier 100000)

and

(area-multiplier 100001)

What should these produce?

Sign up to request clarification or add additional context in comments.

1 Comment

Oh, I understand. I want them to produce the amount of times area was multiplied by 1.5. Therefore, 0 was correct in that spot because it would add 0 to the total and stop recursion. Thanks!
0

What you have is fine, except that if you want 100000 to return 0, then change the < to <=. :-)

1 Comment

I didn't even catch that. Thank you! It turned out I had a fundamental misunderstanding of how recursion worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.