Skip to content

Project Euler Problem 63

December 16, 2011

Project Euler Problem 63 solution is trivial. The only preliminary consideration would be that numbers greater, than 9 cannot yield any n-th powers having n digits:

open System

let nthPowersAmount ``base`` =
    let nDigits n = n.ToString().Length

    let power n (``base``: bigint) =
        [1..n] |> List.fold (fun product _ -> ``base`` * product) 1I

    Seq.unfold (fun n ->
                    if (power n ``base``) |> nDigits <> n then None
                    else Some(1, n + 1)) 1
    |> Seq.length

let problem063 () =
    {1I..9I} |> nthPowersAmount |> Seq.sum

From → Project Euler

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: