I'm stuck at lesson 36 code project Python | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

I'm stuck at lesson 36 code project Python

Pls help, Question sum of consecutive numbers, N =int(input()) Result total sum from 0 to N Help pls!!!

24th May 2021, 6:07 AM
Will Lim
Will Lim - avatar
4 Respostas
+ 6
Will Lim Use range(1, N + 1) in for loop and add each number or just do this without loop sum = N * (N + 1) // 2
24th May 2021, 8:38 AM
AĶ¢J
AĶ¢J - avatar
+ 5
You can use either for-loop or the sum formula.
24th May 2021, 7:28 AM
Gordon
Gordon - avatar
+ 3
Will Lim In which language? How we would know?
24th May 2021, 6:08 AM
AĶ¢J
AĶ¢J - avatar
24th May 2021, 6:11 AM
visph
visph - avatar