Factorial

ai.dragonfly.math.Factorial$
object Factorial

Attributes

Source
Factorial.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Factorial.type

Members list

Value members

Concrete methods

def apply(x: Int): BigInt

Computes !, the factorial, of integers.

Computes !, the factorial, of integers.

Factorial(x) = x! = x * (x-1) * (x-2) * (...) * 2 * 1

Internals:

This implementation relies on scala.math.BigInt to avoid the notorious overflow problems of factorial functions; 13! overflows Int and 21! overflows Long.

for x! where 0 <= x <= 100, returns a cached value. for x! where x > 100, starts with 100! from the cache and iteratively multiplies 101, 102, ... x.

Attributes

Returns

x!

Source
Factorial.scala
def apply(x: Long): BigInt

Computes x!, the factorial(x), of Long x.

Computes x!, the factorial(x), of Long x.

Factorial(x) = x! = x * (x-1) * (x-2) * (...) * 2 * 1

Internals:

This implementation relies on scala.math.BigInt to avoid the notorious overflow problems of factorial functions; 13! overflows Int and 21! overflows Long.

for x! where 0 <= x <= 100, returns a cached value. for x! where x > 100, starts with 100! from the cache and iteratively multiplies 101, 102, ... x.

Attributes

Returns

x!

Source
Factorial.scala
def apply(x: BigInt): BigInt

Computes x!, the factorial(x), of BigInt x.

Computes x!, the factorial(x), of BigInt x.

Factorial(x) = x! = x * (x-1) * (x-2) * (...) * 2 * 1

Internals:

This implementation relies on scala.math.BigInt to avoid the notorious overflow problems of factorial functions; 13! overflows Int and 21! overflows Long.

for x! where 0 <= x <= 100, returns a cached value. for x! where x > 100, starts with 100! from the cache and iteratively multiplies 101, 102, ... x.

Attributes

Returns

x!

Source
Factorial.scala

Concrete fields

val one: BigInt

Attributes

Source
Factorial.scala

Extensions

Extensions

extension (x: Int)(x: Int)
def !: BigInt

Int extension method for ! syntax: Enable postfix ops to support traditional factorial syntax: 3! val i:Int = 9; i! Warning: Consider order of operations carefully: 10 * (4!) yields 240 10 * (4)! yields 815915283247897734345611269596115894272000000000

Int extension method for ! syntax: Enable postfix ops to support traditional factorial syntax: 3! val i:Int = 9; i! Warning: Consider order of operations carefully: 10 * (4!) yields 240 10 * (4)! yields 815915283247897734345611269596115894272000000000

Without postifx ops: 3.! val i:Int = 9; i.!

Attributes

Returns

x!

Source
Factorial.scala
extension (x: Long)(x: Long)
def !: BigInt

Attributes

Source
Factorial.scala
extension (x: BigInt)(x: BigInt)
def !: BigInt

Attributes

Source
Factorial.scala