cours-info/Somme2.java

29 lines
327 B
Java
Raw Permalink Normal View History

2019-06-01 16:45:55 +00:00
import static utils.Utils.*;
public class Somme2 {
public static final void main(String[] args) {
afficher("Somme 2");
testSomme2(Somme2::somme2);
}
public static final int somme2(int n, int p) {
2019-06-17 15:37:53 +00:00
if (n<=p){
int r=0;
for (int q=n; q<=p; q++){
r=r+q;
}
return r;
}
else {
return somme2(p,n);
}
}
2019-06-01 16:45:55 +00:00
}