the lost developer

mostly .NET stuff

Project Euler - Problem Fourteen F# edition

clock June 3, 2008 11:29 by author eric

Skipping around again, Problem 14 states:

The following iterative sequence is defined for the set of positive integers:

nn/2 (n is even)
n → 3n + 1 (n is odd)

Using the rule above and starting with 13, we generate the following sequence:

13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1

It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1.

Which starting number, under one million, produces the longest chain?

I wrote a very simple implementation of this problem in F#: More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Project Euler - Problem Nine

clock May 29, 2008 19:23 by author eric

Yes, I know I skipped problem 8, but it involves strings, and I found nine easier to do More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Project Euler - Problem Six

clock May 25, 2008 11:39 by author eric

The sum of the squares of the first ten natural numbers is,

1² + 2² + ... + 10² = 385

The square of the sum of the first ten natural numbers is,

(1 + 2 + ... + 10)² = 55² = 3025

Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.

Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

This problem is easy in both C# and F# More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Project Euler - Problem Five

clock May 25, 2008 11:04 by author eric

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?

This is a problem that can be brut forced. More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Project Euler - Problem Four

clock May 25, 2008 09:52 by author eric

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

The easiest way to reverse a number is to convert the number to a string then to a character array and call reserve More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Project Euler - Prime Numbers - Problem Three and Seven

clock May 25, 2008 09:33 by author eric

 

Many of the Project Euler problems require prime number to solve, so I wrote a prime number generator in both F# and C#.  I think that my implementation in C# is more efficient More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Project Euler - Problem Two (YAPES)

clock May 16, 2008 14:25 by author eric

Problem Two is defined as

 

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

Find the sum of all the even-valued terms in the sequence which do not exceed four million.

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Project Euler - Problem One (YAPES)

clock May 16, 2008 12:08 by author eric

In order to learn F#, I decided to work through the Project Euler problem sets. More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Search

    Calendar

    <<  January 2009  >>
    SuMoTuWeThFrSa
    28293031123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    Archive

    Tags

    Categories


    Blogroll

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2009

    Sign in