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

  • Home
  • SEARCH
  • 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 6070271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:54:51+00:00 2026-05-23T09:54:51+00:00

Here is a question: By listing the first six prime numbers: 2, 3, 5,

  • 0

Here is a question:

By listing the first six prime
numbers: 2, 3, 5, 7, 11, and 13, we
can see that the 6th prime is 13.

What is the 10001st prime number?

Here is my solution:

#lang racket

(define (search-limit num)
  (+ (floor (sqrt num)) 1))

(define (search-list num)
  (stream->list (in-range 2 (search-limit num))))

(define (divided? num x)
  (= (remainder num x) 0))

(define (list-of-dividers num)
  (filter (lambda (x)
            (divided? num x))         
       (search-list num)))

(define (prime? num)
  (= (length (list-of-dividers num)) 0))

(define (problem_7 current_prime primes counter)
  (cond
    [(< primes 10001)
     (cond
       [(prime? counter) (problem_7 counter (+ primes 1) (+ counter 1))]
       [else (problem_7 current_prime primes (+ counter 1))])]
    [else current_prime]))

(problem_7 0 0 0)

It works but works slowly. I am sure that there is a better solution.
Can you give me the more scheme-way 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-05-23T09:54:52+00:00Added an answer on May 23, 2026 at 9:54 am

    I did it the following way, which takes under 1 second on my computer (your version took about 12.5 seconds):

    #lang racket
    
    (define (divides? n div)
      (= (remainder n div) 0))
    
    (define (prime? n)
      (prime-helper n 2))
    
    (define (prime-helper n start)
      (cond ((> start (sqrt n)) #t)
            ((divides? n start) #f)
            (else (prime-helper n (+ 1 start)))))
    
    (define (prob7_helper n count)
      (cond ((= 10001 count) (- n 1))
            ((prime? n) (prob7_helper (+ 1 n) (+ 1 count)))
            (else (prob7_helper (+ 1 n) count))))
    
    (define (prob7) (prob7_helper 2 0))
    
    (prob7)
    

    There are certainly faster implementations of (prime? n), but this does the trick for me.

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

Sidebar

Related Questions

first question here. I'm developing a program in C# (.NET 3.5) that displays files
this is my first question here so I hope I can articulate it well
I've got a really simple rails question here but I can't seem to find
I found a question here about blogs on software development, but I would like
There is a similar question here but it only covers some of the issues
Based on my previous question here my new concern is how do I unit
Pardon the dumb newbie question here; web programming isn't my forte... (blush) I have
I was going to ask a question here about whether or not my design
Forgive me for a potentially silly question here, but in other programming languages (scripting
As a secondary method to my question here: Show Cell Range on UserForm; then

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.