From 7843ea57c2713f3854426dde3614e833d27d8f31 Mon Sep 17 00:00:00 2001 From: Meutel Date: Mon, 17 Jun 2019 17:37:53 +0200 Subject: [PATCH] Exercice somme entre 2 entiers --- Somme2.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Somme2.java b/Somme2.java index 2da2342..853bbdd 100644 --- a/Somme2.java +++ b/Somme2.java @@ -9,7 +9,20 @@ public class Somme2 { } public static final int somme2(int n, int p) { - return 0; - } + +if (n<=p){ + int r=0; + + for (int q=n; q<=p; q++){ + r=r+q; +} +return r; + +} + +else { + return somme2(p,n); +} +} }