23 lines
584 B
FSharp
23 lines
584 B
FSharp
module _57
|
|
|
|
open common
|
|
open Fraction
|
|
open System
|
|
open System.Numerics
|
|
|
|
let sqrtTwoDigits =
|
|
let sqrtTwoConvergent d =
|
|
let rec sqrtTwo = function
|
|
| 1 -> (2I,1I)
|
|
| d -> addI (2I,1I) (reciprocalI(sqrtTwo (d - 1)))
|
|
addI (1I,1I) (reciprocalI(sqrtTwo d))
|
|
|
|
let digitCount n =
|
|
let d = BigInteger.Log10(n)
|
|
Math.Floor d + 1.0 |> int
|
|
|
|
[1..1000]
|
|
|> List.map sqrtTwoConvergent
|
|
|> List.map (fun (n,d) -> (digitCount n, digitCount d))
|
|
|> List.mapi (fun i (n,d) -> i + 1, n > d)
|
|
|> List.filter (snd >> ((=) true)) |