#xkcd #variables #numbers #base #system #factoradic #com-2835

bin+lib variable_base_factoradic

Rust implementation of Randall Munroe's variable base factoradic number system: https://xkcd.com/2835/

1 unstable release

0.0.1 Oct 30, 2023

#14 in #xkcd

MIT license

6KB
76 lines

Variable-base Factoradic numbers

Implementation of https://xkcd.com/2835/

Installation

https://crates.io/crates/variable_base_factoradic

cargo install variable_base_factoradic

Usage

use variable_base_factoradic::VariableBaseFactoradicNumber;

// Convert from decimal to factoradic
let v = VariableBaseFactoradicNumber::try_new(5038).unwrap();
println!("{}", v.to_string()); // 654320

// Convert from factoradic to decimal
let v = "654320".parse::<VariableBaseFactoradicNumber>().unwrap();
println!("{}", v.value); // 5038

No runtime deps