Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Learn more about F# at http://fsharp.net
- // See the 'F# Tutorial' project for more help.
- let giga a b =
- if a > b then
- a
- else
- b
- let gigaSum arr =
- let mutable sum = 0
- for a in arr do
- sum <- sum + a // Assign value to the existing sum variable.
- sum
- let rec gigaUsg a b =
- let mutable x = a
- let mutable y = b
- if x = y then
- x
- elif x > y then
- x <- x - y
- gigaUsg x y
- else
- y <- y - x
- gigaUsg x y
- let rec prime (p:int) (k:int):bool =
- if k > p / 2 then
- true
- else
- let k = k + 2
- if p % k = 0 then
- false
- else
- prime p k
- let rec exponent (x:double) (n:double) (y:double):double =
- if y > 0.00000000001 then
- let n = n + 1.0
- let y = y * x / n
- y + exponent x n y
- else
- 1.0
- [<EntryPoint>]
- let main argv =
- let m = 7
- let k = 8
- let r = giga m k
- printfn "Pasuxia: %d" r
- let arr = [|1; 2; 3; 4; 5|]
- printfn "Masivis elementi: %d" arr.[0]
- let sum = gigaSum arr
- printfn "Sum is: %d" sum
- printfn "GCD: %d" (gigaUsg 75 30)
- printfn "Is 195 prime? %b" (prime 195 1)
- printfn "Is 97 prime? %b" (prime 97 1)
- printf "Exponent: %f" (exponent 2.0 0.0 1.0)
- 0 // return an integer exit code
Add Comment
Please, Sign In to add comment