+ 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)
6 odpowiedzi
+ 1
iskajir you are my best friend!!!!!
+ 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:
+ 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
+ 1
okay but is there a way to do this with loops?
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