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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:27:14+00:00 2026-05-13T20:27:14+00:00

I am learning the ropes of F# through Project Euler, and ran into the

  • 0

I am learning the ropes of F# through Project Euler, and ran into the following issue a few times. I write a function, run it in the F# interactive window, and the program hangs there. I suspect the function is failing, but I am not getting any significant error message which would help me figure out what is going wrong. Is there any way to debug a program running in F# interactive?
As an illustration, here is an example, from Problem 12. FindFirstTriangle(0,0,100) runs fine, but when the divisor is around 150, things get stuck.
Note: this is not about what is wrong about this code, but about how to figure out where things go wrong!

let NumberOfDivisors n =
  [1 .. n] |> List.filter (fun i -> n % i = 0) |> List.length;;

let HasMoreThanDDivisors n d =
  if NumberOfDivisors n >= d then
    true
  else
    false

let rec FindFirstTriangle (index, number, divisors) =
  if HasMoreThanDDivisors number divisors then
    number
  else
    let nextIndex = index + 1
    let nextNumber = number + index
    FindFirstTriangle (nextIndex, nextNumber, divisors);;
  • 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-13T20:27:15+00:00Added an answer on May 13, 2026 at 8:27 pm

    If you have e.g. ‘windows task manager’ running you’ll see that your CPU is running flat out while the thing is hung. You’ve just created too much work; you need a more efficient algorithm. Press the ‘interrupt’ key in F# interactive (Ctrl-. in the FSI window in Visual Studio) to stop processing.

    If the big-oh isn’t clear, you might consider adding some prints to show how much work is being done. E.g.

    let NumberOfDivisors n = 
      printf "%d" n // added
      seq {1 .. n} |> Seq.filter (fun i -> n % i = 0) |> Seq.length;; 
    
    let HasMoreThanDDivisors n d = 
      if NumberOfDivisors n >= d then 
        true 
      else 
        false 
    
    let rec FindFirstTriangle (index, number, divisors) = 
      printfn "" // added
      if HasMoreThanDDivisors number divisors then 
        number 
      else 
        let nextIndex = index + 1 
        let nextNumber = number + index 
        FindFirstTriangle (nextIndex, nextNumber, divisors);;
    

    and then run FindFirstTriangle with larger and larger numbers to get a sense of what’s happening.

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

Sidebar

Related Questions

I'm still learning the WPF ropes, so if the following question is trivial or
Learning python for two days :) and now I attempting to solve Project Euler
I'm still learning the ropes of Git (love it!) but the other day I
im not the best when it comes to SQL still learning the ropes. I
Please bear with me, newbie just learning the ropes. I am getting the below
Learning a lot in my few years of programming that the best projects are
Ok, so I'm still learning the ropes of C++ here so I apologize if
I'm still learning the ropes for Entity expressions, and I have this SQL query
I'm still learning the ropes of OLAP, cubes, and SSAS, but I'm hitting a
... and thanks for reading... I'm still learning the ropes so please be forgiving...

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.