Skip to content

Instantly share code, notes, and snippets.

@samcv
Created September 1, 2017 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samcv/77c241e6d25c035213ea6230c6011a01 to your computer and use it in GitHub Desktop.
Save samcv/77c241e6d25c035213ea6230c6011a01 to your computer and use it in GitHub Desktop.
static size_t length_of_num (size_t number) {
if (number < 10) return 1;
if (number < 100) return 2;
if (number < 1000) return 3;
return 1 + length_of_num(number / 10);
}
static size_t length_of_num (size_t number) {
if (number < 10) return 1;
return 1 + length_of_num(number / 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment