Factorial
Attributes
- Source:
- Factorial.scala
- Graph
- Supertypes
- Self type
- Factorial.type
Members list
Value members
Concrete methods
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
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
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
Attributes
- Source:
- Factorial.scala
Extensions
Extensions
Attributes
- Source:
- Factorial.scala
Attributes
- Source:
- Factorial.scala
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