Skip to content

Instantly share code, notes, and snippets.

@dgodfrey206
Created January 31, 2015 01:11
Show Gist options
  • Save dgodfrey206/8bd87dd6e8b55f654fb3 to your computer and use it in GitHub Desktop.
Save dgodfrey206/8bd87dd6e8b55f654fb3 to your computer and use it in GitHub Desktop.
Java recursion
public int count8(int n) {
int m = n/10;
boolean b = n%10==8;
return n==0 ? 0 : count8(n/10) + (b ? ((b && m%10==8) ? 2 : 1) : 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment