Hi I'm new at coding and I tried something but I have no idea how to solve this. I hope ( I'm pretty sure) you can help me ! Ty! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Hi I'm new at coding and I tried something but I have no idea how to solve this. I hope ( I'm pretty sure) you can help me ! Ty!

I'm trying to code a little program that counts from 1 to 100 and when it reaches 100 it counts again but this time til 99 and so on untill it stops at 1. it also adds together 100 + 99 + 98....etc can u help me? I'm tired after 6 hours x_x (with resting ofc =p)

17th Jun 2018, 1:02 AM
iskajir
iskajir - avatar
6 Answers
+ 1
iskajir you are my best friend!!!!!
28th Jul 2018, 12:19 AM
Korhall
Korhall - avatar
+ 1
Could you provide a link to the code that you're using to test out this problem? It would just make it a little easier to troubleshoot that way d:
17th Jun 2018, 2:12 AM
Faisal
Faisal - avatar
+ 1
oh yea forgot that. The problem is that I'm trying to take 1 minus of y when x reaches the same number like y and reset x to 0. but I guess there is somewhere an infinite loop right? https://code.sololearn.com/cZ18gkqjm10U/?ref=app
17th Jun 2018, 8:49 AM
iskajir
iskajir - avatar
+ 1
okay but is there a way to do this with loops?
17th Jun 2018, 9:33 AM
iskajir
iskajir - avatar
0
there's a math formula for this. the sum of numbers from 1 to n is equal to: (n*(n+1))/2 no need to use loops
17th Jun 2018, 9:20 AM
hinanawi
hinanawi - avatar