#digits #numbers #reduce #u64 #u8

numred

A library to reduce any number to just one digit. The numred function takes an &u64 and returns an u8.

1 unstable release

0.1.0 Oct 8, 2019

#34 in #reduce

MIT license

3KB

numred

A library to reduce any number to just one digit. The numred function takes an &u64 and returns an u8. It operates this way:

Given a number like 12, it returns 3 Given a number like 10, it returns 1 Given a number like 123, it returns 6

So, it sums each digit with the result of the previous ones, and if it is greater than 10, it sums also this two digits (11 -> 2, 12 -> 3 and so on).

Corrections are welcome. Just contact me for any suggestion.

No runtime deps