Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding solution for problem 25
  • Loading branch information
sfoutrier committed Apr 1, 2012
1 parent ecc6c0f commit eaeae7c
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Euler.sln
Expand Up @@ -49,6 +49,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Euler23", "Euler23\Euler23.
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Euler24", "Euler24\Euler24.fsproj", "{A4AB3E64-D504-4D9D-B48B-53742A779EF5}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Euler25", "Euler25\Euler25.fsproj", "{58B283F6-14DE-48D3-9E30-474DC2429E70}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Expand Down Expand Up @@ -151,6 +153,10 @@ Global
{A4AB3E64-D504-4D9D-B48B-53742A779EF5}.Debug|x86.Build.0 = Debug|x86
{A4AB3E64-D504-4D9D-B48B-53742A779EF5}.Release|x86.ActiveCfg = Release|x86
{A4AB3E64-D504-4D9D-B48B-53742A779EF5}.Release|x86.Build.0 = Release|x86
{58B283F6-14DE-48D3-9E30-474DC2429E70}.Debug|x86.ActiveCfg = Debug|x86
{58B283F6-14DE-48D3-9E30-474DC2429E70}.Debug|x86.Build.0 = Debug|x86
{58B283F6-14DE-48D3-9E30-474DC2429E70}.Release|x86.ActiveCfg = Release|x86
{58B283F6-14DE-48D3-9E30-474DC2429E70}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
56 changes: 56 additions & 0 deletions Euler25/Euler25.fsproj
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{58b283f6-14de-48d3-9e30-474dc2429e70}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Euler25</RootNamespace>
<AssemblyName>Euler25</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<Name>Euler25</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Debug\Euler25.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Release\Euler25.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="!Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" />
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
15 changes: 15 additions & 0 deletions Euler25/Program.fs
@@ -0,0 +1,15 @@
// http://projecteuler.net/problem=25

[<EntryPoint>]
let main args =

let fibo = Seq.unfold (function
| a, b, pos when a = bigint.Zero && b = bigint.Zero -> Some((bigint.One, pos), (bigint.One, bigint.Zero, pos + 1))
| a, b, pos -> Some((a + b, pos), (a + b, a, pos + 1))
) (bigint.Zero, bigint.Zero, 1)


printfn "%d" (Seq.pick (function x, _ when (bigint.Log10 x) < 999. -> None | _, pos -> Some (pos)) fibo)

let _ = System.Console.ReadKey true
0

0 comments on commit eaeae7c

Please sign in to comment.