Skip to content

Instantly share code, notes, and snippets.

@thecoducer
Last active July 18, 2019 07:22
Show Gist options
  • Save thecoducer/c80cb1e58a22eb60405d5be6d2d2cb13 to your computer and use it in GitHub Desktop.
Save thecoducer/c80cb1e58a22eb60405d5be6d2d2cb13 to your computer and use it in GitHub Desktop.
// Since the result can be large
// long long is used as return type
long long countdigits(int n){
if(n <= 1)
return n;
else{
double x = ((n * log10(n / M_E)) + (log10(2 * M_PI * n) / 2.0));
return floor(x) + 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment