0 people like it.

SmallestDivNumber.fsx

Smallest divisible number between 1 to any number.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
let maxDiv = 20
let mutable num = 1

let chkDiv num =
    seq {1..maxDiv}
    |> Seq.forall 
        (fun x -> num % x = 0)

while not <| (chkDiv num) 
    do num <- num + 1
    
printfn "Number Found : %d" num
val maxDiv : int

Full name: Script.maxDiv
val mutable num : int

Full name: Script.num
val chkDiv : num:int -> bool

Full name: Script.chkDiv
val num : int
Multiple items
val seq : sequence:seq<'T> -> seq<'T>

Full name: Microsoft.FSharp.Core.Operators.seq

--------------------
type seq<'T> = System.Collections.Generic.IEnumerable<'T>

Full name: Microsoft.FSharp.Collections.seq<_>
module Seq

from Microsoft.FSharp.Collections
val forall : predicate:('T -> bool) -> source:seq<'T> -> bool

Full name: Microsoft.FSharp.Collections.Seq.forall
val x : int
val not : value:bool -> bool

Full name: Microsoft.FSharp.Core.Operators.not
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
Raw view Test code New version

More information

Link:http://fssnip.net/mN
Posted:10 years ago
Author:FoXyCon
Tags: smallest divisible number , tryfsharp