Problem #57 says:
It is possible to show that the square root of two can be expressed as an infinite continued fraction.
√ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + … ))) = 1.414213…
By expanding this for the first four iterations, we get:
1 + 1/2 = 3/2 = 1.5
1 + 1/(2 + 1/2) = 7/5 = 1.4
1 + 1/(2 + 1/(2 + 1/2)) = 17/12 = 1.41666…
1 + 1/(2 + 1/(2 + 1/(2 + 1/2))) = 41/29 = 1.41379…
The next three expansions are 99/70, 239/169, and 577/408, but the eighth expansion, 1393/985, is the first example where the number of digits in the numerator exceeds the number of digits in the denominator.
In the first one-thousand expansions, how many fractions contain a numerator with more digits than denominator?
The fastest way to attach this one is to treat it as a sequence and find the pattern required to expand it. for the numerator to take the previous denominator and multiple it by two then add the previous numerator to it, for the denominator you just add the previous numerator and denominator together. This gets really big really fast so we’ll use the biginteger class in .net 4. then we just check the string length of the numerator and denominator and see which is larger. wash rinse and repeat.
Solution in f# and requires .net 4.0 Runs in (5* (10^6)) seconds or 65 ticks on my netbook.
open System
open System.Diagnostics
let sw = new Stopwatch()
sw.Start()
let num n d = (2I*d)+n
let den n d = n+d
let rec Answer n d c count =
if c > 1000 then
count
else
if n.ToString().Length > d.ToString().Length then
Answer (num n d) (den n d) (c+1) (count+1)
else
Answer (num n d) (den n d) (c+1) count
sw.Stop()
Console.WriteLine(Answer 3I 2I 0 0)
Console.WriteLine(sw.Elapsed.Ticks)
Console.ReadLine() |> ignore
Tags: .net4, f#, project euler
Posted in General | Comments (0)
Because there’s nothing like running through a town with a sledgehammer destroying anything that moves…
Definitely one of the most entertaining games, the vehicles handle well, and there is a lot of weapons to choose from when planning how your going to attack the EDF. Plus you get a rifle that eats people alive!

Posted in General, Software | Comments (0)
So I know that I haven’t been posting anything programming related for a while, and that’s mostly because I’ve been working on boring projects, so instead you get a random thought.
So anyway, It occurred to me that with the coming widespread use of nanotechnology to create and replicate things that the value of the original item for being an original is moot. For example if you can use nanotechnology to recreate a famous painting atom by atom then the original painting cannot be differentiated from the copies. they would be in essence perfect copies. More so, since you are creating the copy atom by atom then you can also defeat methods such as carbon dating, which works be determining the proportion of carbon isotopes to each other in a sample. However if your building something from individual atoms you can control this ration by doping the construction materials with the appropriate levels of isotopes. At that point every crack in the painting (craquelure), the carbon dating age and the appearance of the copy would be the exact same. and since the copy and the original are Identical to each other down to the atomic makeup there would be no way to tell them apart. thus nanotechnology will destroy the antiquities market by making it impossible to determine if what your paying millions for is an original Rembrandt or merely a nanoforged copy…
Tags: future, nanotech, wth
Posted in General | Comments (0)
Between college classes (Algorithm and Data-structures, calculus and analytical geometry, statistics, and eng 101) and work, I’ve been swamped and haven’t really gotten the chance to work on anything nifty in the programming world. I’ve managed to start reading Mono: A Developer’s Notebook
which has been an interesting read.I’ve also started to build up some of my internet properties so they aren’t going to waste, which is taking some time (I’ve collected a lot of domain names). I’m hoping to get back to doing updates at least weekly sometime soon, so check back sometime this week for the regular update.
Posted in General | Comments (0)
Ok, everybody. Code segments should be back up. Switched to a new plugin for code handling, had to update all of the articles that used some features of the old one. so anyways everything should be back up.
Posted in General | Comments (0)