↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Using “Project Euler” to Learn F# – Problems 6, 7, 8, 9 and 10

The author continues learning F# through Project Euler and says that, without time for a larger project, he solved problems 6, 7, 8, 9, and 10. For each problem, he presents an F# solution and shows the use of functions, sequences, and prime-number searches.

Reading notes
#

  • The text uses Project Euler as practice for learning F# while the author is not working on a larger project.
  • Problem 6 is solved with a function that calculates the difference between the sum of squares and the square of the sum for a given range.
  • Problem 7 uses a recursive function to test primality and obtain the n-th prime number.
  • Problem 8 builds the 1000-digit number, converts its characters to integers, and looks for the greatest product among adjacent digit sequences.
  • Problem 9 generates Pythagorean triplets with Euclid’s formula and searches for the only one whose sum is 1000.
  • Problem 10 reuses the prime function to sum all primes below a given limit.
  • The text ends by saying “That was it.”