public class Test {
public static void main(String[] args) {
print(4);
}
static void print(int n){
if (n <= 1)
System.out.print("A");
else {
print(n-1);
print(n-2);
}
}
}
The output result of this code is AAAAA. But I want to know how? When do I consider (n-1) and when (n-2)?
Aucun commentaire:
Enregistrer un commentaire