//! # My Crate //! //! `my_crate` is a collection of utilities to make performing certain //! calculations more convenient. /// Adds one to the number given. // --snip-- pub use convert::exp; pub use convert::level; pub mod convert { fn calc(stage: i64, amount: i64) -> i64 { amount * (stage * 100) } /// convert level into exp pub fn exp(level: i64) -> i64 { let s = (level / 10) + 1; let r: i64 = level % 10; let mut l: i64 = calc(s, r); for cs in 1..s { l += calc(cs, 10) } l } /// convert exp into level pub fn level(exp: i64) -> i64 { let mut x: i64 = 0; let mut l: i64 = 0; let mut s: i64 = 0; loop { s += 1; let x2 = x + calc(s, 10); if x2 >= exp { l += (exp - x) / calc(s, 1); break } x = x2; l += 10 } l } } fn main() { println!("{}", convert::exp(102)) }