java write recursive function that accept int : k and print to screen k of "*"
Attempt:
public static String numStarec(int k) {
String ans = "";
if (k == 0) {
ans += "*";
return ans;
}
return numStarec(k-1);
}
this code not work and print for me only "*" ones I know the problem
I tried to fix that but , unfortunately without successes
Example :
k = 3
console : ***