Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
It is minor, but instead of these num -= billions * 1_000_000_000; calculations you could use simply num %= 1_000_000_000; compound assignment operator.