F# code to check whether there are three same digits within a given number I came across this problem by accident and gave it a go. I think my solution works as it has passed all the unit tests I wrote. Given I just started learning F# a couple of weeks I would love to have some feedback on the code regarding both its accuracy and its quality. 

To be clear about the problem, given an integer number, check whether the number has at least 3 same digits in it e.g. 1222, 12222, 222, 123123123 are both counted as yes. 

module Miscellaneous = 
    let (|ThreeSame|_|) = function
        | (l : int list) when l.Length &gt; 20 -&gt; Some()
        | x :: y :: z :: _ when x = y &amp;&amp; y = z -&gt; Some()
        | _ -&gt; None

    ///&lt;summary&gt;
    /// Given any integer convert its digits into a list
    ///&lt;/summary&gt;
    ///&lt;param name="number"&gt;The integer&lt;/param&gt;
    ///&lt;returns&gt;
    ///A int list
    ///&lt;/returns&gt;
    let convertNumberToList (number: bigint) = 
        let numberString = string number
        numberString.ToCharArray() 
        |&gt; Array.map (string &gt;&gt; int) //use composition to replace (fun x -&gt; int (string x))
        |&gt; Array.toList

type NumberCheck() =
        ///&lt;summary&gt;
        /// A helper function to check whether a list of numbers contains three or more
        /// same numbers
        ///&lt;/summary&gt;
        ///&lt;param name="l"&gt;The list to be checked&lt;/param&gt;
        ///&lt;param name="sorted"&gt;The flag to indicate whether the given list is sorted or not&lt;/param&gt;
        ///&lt;returns&gt;
        /// True if there are at least 3 same numbers; False otherwise
        ///&lt;/returns&gt;
        static member private TripleNumberHelper(l : int list, ?sorted) =
            if l.Length &lt; 3 then false
            else
                if defaultArg sorted false then
                    match l with
                    | Miscellaneous.ThreeSame -&gt; true
                    | _ -&gt; NumberCheck.TripleNumberHelper(l.Tail, true)
                else
                    let sortedList = l |&gt; List.sort
                    match sortedList with
                    | Miscellaneous.ThreeSame -&gt; true
                    | _ -&gt; NumberCheck.TripleNumberHelper(sortedList.Tail, true)

        ///&lt;summary&gt;
        /// Test whether a number has 3 or more same digits in it
        ///&lt;/summary&gt;
        ///&lt;param name="number"&gt;The number to be checked&lt;/param&gt;
        ///&lt;returns&gt;
        ///Ture of False
        ///&lt;/returns&gt;
        static member TripleNumber(number : bigint) = 
            let l = Miscellaneous.convertNumberToList number
            NumberCheck.TripleNumberHelper(l)
Followed upon @hocho's comment and agree that using groupBy is much better as it can generalise the solution to check any number of same digit rather than limited to just 3 from my initial implementation. I have also simplified the helper method which converts a number into a collection; returning a sequence is enough as there is no need to return an array.

let convertNumberToSeq (number: bigint) = 
        let numberString = string number
        numberString.ToCharArray() 
        |&gt; Seq.map (string &gt;&gt; int)

///&lt;summary&gt;
/// Check whether a given number has at least n same digits
///&lt;/summary&gt;
///&lt;param name="number"&gt;The given number&lt;/param&gt;
///&lt;param name="n"&gt;How many same digits to be checked&lt;/param&gt;
///&lt;returns&gt;
///True if there are n same digits otherwise False
///&lt;/returns&gt;
let SameDigitCheck (number : bigint) (n : int) = 
    if n &lt; 2 then failwith "n must be at least 2"
    let digits = convertNumberToSeq number
    let q = query { for digit in digits do groupBy digit into g; select g }
    q |&gt; Seq.exists (fun x -&gt; Seq.length x &gt;= n)