Skip to content

Instantly share code, notes, and snippets.

@Tekaichi
Created October 26, 2017 16:17
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 Tekaichi/defb23425f83eb7adfbac3bebe6542c2 to your computer and use it in GitHub Desktop.
Save Tekaichi/defb23425f83eb7adfbac3bebe6542c2 to your computer and use it in GitHub Desktop.
RECURSIVE EXERCICIOS
private static void recSeparate(int[] v, int i, List<Integer> list, int threshold) {
if(i == v.length){
return;
}
if(v[i] < threshold){
recSeparate(v,i+1,list,threshold);
list.addFirst( v[i]);
}else{
list.addLast(v[i]);
recSeparate(v,++i,list,threshold);
}
}
public static int countDigit(int n, int digit) {
if ((n % 10) == digit) {
return 1 + countDigit(n / 10, digit);
} else if (n / 10 != 0) {
return countDigit(n / 10, digit);
} else {
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment