Top Level Namespace
Defined in:
Method Summary
-
coprime(a : Int, b : Int) : Bool
Returns boolean indicating whether a and b are coprime numbers.
-
fac(n : Int) : Int
Returns factorial value of number n.
-
fib(n : Int) : Int
Returns fibonacci value of number n.
-
gcd(a : Int, b : Int) : Int
Returns greatest common divisor value of numbers a and b.
-
isprime(n : Int) : Bool
Returns boolean indicating wether number n is a prime number.
-
maxsub(array : Array(Int)) : Int
Returns integer value of the contiguous subarray within a one-dimensional array of numbers.
Method Detail
def coprime(a : Int, b : Int) : Bool
#
Returns boolean indicating whether a and b are coprime numbers.
coprime(2, 2) # => false
coprime(13, 27) # => true
def gcd(a : Int, b : Int) : Int
#
Returns greatest common divisor value of numbers a and b.
gcd(12, 24) # => 12
gcd(2, 19) # => 1
def isprime(n : Int) : Bool
#
Returns boolean indicating wether number n is a prime number.
isprime(1) # => false
isprime(13) # => true
def maxsub(array : Array(Int)) : Int
#
Returns integer value of the contiguous subarray within a one-dimensional array of numbers.
maxsub([-2, 1, -3, 4, -1, 2, 1, -5, 4]) # => 6