View source code
Display the source code in std/numeric.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.numeric.decimalToFactorial
This function transforms decimal
value into a value in the factorial number
system stored in fac
.
ulong decimalToFactorial
(
ulong decimal,
ref ubyte[21] fac
) pure nothrow @nogc @safe;
A factorial number is constructed as:
fac[0] * 0! + fac[1] * 1! + ... fac[20] * 20!
Parameters
Name | Description |
---|---|
decimal | The decimal value to convert into the factorial number system. |
fac | The array to store the factorial number. The array is of size 21 as
ulong requires 21 digits in the factorial number system. |
Returns
A variable storing the number of digits of the factorial number stored in
fac
.
Example
ubyte[21] fac;
size_t idx = decimalToFactorial(2982, fac);
writeln(fac[0]); // 4
writeln(fac[1]); // 0
writeln(fac[2]); // 4
writeln(fac[3]); // 1
writeln(fac[4]); // 0
writeln(fac[5]); // 0
writeln(fac[6]); // 0
Authors
Andrei Alexandrescu, Don Clugston, Robert Jacques, Ilya Yaroshenko
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.