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 8449515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:43:48+00:00 2026-06-10T10:43:48+00:00

My iterative solution to SICP 1.37 is (define (con-frac n d k) (define (iter

  • 0

My iterative solution to SICP 1.37 is

(define (con-frac n d k)
  (define (iter i result)
    (if (= 1 i)
        result
        (iter (- i 1) (/ (n i) (+ (d i) result)))))
  (iter k (/ (n k) (d k))))

(con-frac (lambda (i) 1.0) (lambda (i) 1.0) 11)

(define (euler-d i)
  (if (= 2 (remainder i 3))
      (* (/ 2 3) (+ i 1))
      1))

(define (e)
  (+ 2 (con-frac (lambda (i) 1.0) euler-d 9)))

(e)

It returns:

Welcome to DrRacket, version 5.2.1 [3m].
Language: SICP (PLaneT 1.17); memory limit: 128 MB.
0.6180555555555556
2.39221140472879

It should be return:

Welcome to DrRacket, version 5.2.1 [3m].
Language: SICP (PLaneT 1.17); memory limit: 128 MB.
0.6180555555555556
2.718283582089552

I don’t know what’s wrong with my solution.

  • 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-06-10T10:43:50+00:00Added an answer on June 10, 2026 at 10:43 am

    You are off by one in the iter.

    In

      (define (iter i result)
        (if (= 1 i)
            result
            (iter (- i 1) (/ (n i) (+ (d i) result)))))
    

    change (= 1 i) to (= 0 i.

      (define (iter i result)
        (if (= 0 i)
            result
            (iter (- i 1) (/ (n i) (+ (d i) result)))))
    

    The test using phi doesn’t catch this since all numerators and denominators are equal.

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

Sidebar

Related Questions

I was just going through the iterative version of fibonacci series algorithm. I found
I'm currently implementing iterative solvers, which work by successively improving the estimate the solution
I am stuck with my solution to problem 4 of Project Euler, I have
This is actually a solution to Project Euler Problem 14 in F#. However, I'm
At the moment my solution is to iterate through the map to solve this.
I want avoid iterating over a nil array. My bad solution: if nil!=myArr myArr.each
I'm doing an iterative computation on a flow network during which I need to
I'm writing an iterative function to search a binary tree for a certain value.
Iam trying to create an iterative server based on datagram sockets (UDP). It calls
I've been trying to write an iterative dir in c. I began with a

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.