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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:38:13+00:00 2026-06-12T11:38:13+00:00

I was going over some problems for my discrete math class, and read an

  • 0

I was going over some problems for my discrete math class, and read an exercise that caught my attention (note: this is not homework. I’m just purely curious).

Question: How many times is the “print” statement executed for the following program segment? (i, j, k, m are integers):

for i := 1 to 20 do
    for j := 1 to i do
        for k := 1 to j do
            for m := 1 to k do
                print (i * j) + (k * m)

I tried to do it in python, but it was boring because I got it done in a few seconds. So for fun I tried to do it with DrRacket using scheme as the language. However, after reading documentation on loops, I can’t seem to find reference for loops of this kind. So, using this specific example (or I guess a general one with an indefinite number of loops), how can this problem be solved?

  • 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-12T11:38:14+00:00Added an answer on June 12, 2026 at 11:38 am

    A loop like this:

    for i := 1 to 20 do
        for j := 1 to i do
            print [i, j]
    

    Is equivalent to this in Racket, assuming that a loop range that looks like this: 1 to 20 includes all the numbers from 1 up to (and including) 20.

    #lang racket
    
    (for* ((i (in-range 1 21))
           (j (in-range 1 (add1 i))))
      (displayln (list i j)))
    

    Notice that the above is not limited to one nested loop, you can declare as many nested loops and iteration variables as needed.

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

Sidebar

Related Questions

Hi I am having some problems with my javascript not working in IE. That
I was going over some old C code (listed below) with a view to
I am going over/studying the facebook code that was leaked in 2007, I notice
I have been going over the practicality of some of the new parallel features
I'm working on some code that calls a service. This service call could fail
Hello All at StackOverflow, over the last few days I have had some problems
I'm going over the jquery widget here: http://blog.davidpadbury.com/2010/10/11/bdd-testing-of-jquery-plugins-using-jasmine/ The plugin is called like so:
I am going over a past paper for a database course I am taking
So we start Scrum today and start going over story points estimates. The first
I've moved to a new project team and while going over the codebase, found

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.