a est un chiffre (0–9) : calcule s = a + aa + aaa + …, avec n termes au total, le terme i étant formé de i fois le chiffre a. Écris sum_a(a, n). Par exemple, avec a = 2, n = 5 : 2 + 22 + 222 + 2222 + 22222 = 24690. Les nombres deviennent grands, d’où long long.
sum_a(2, 5)→24690sum_a(1, 3)→123long long sum_a(int a, int n)long long sum_a(int a, int n) {
long long term = 0, s = 0;
for (int i = 1; i <= n; i++) {
// ton code ici: ajoute un a à la fin de term, puis ajoute term à s
}
return s;
}
Exécuter teste les exemples. Quand ils sont bons, appuie sur Envoyer.