accept input
i=1,sum = 0;
while sum
sum = 0;
FOR i =1 and i <= sum
sum = sum +i
i++
END FOR
display (sum)
I used 10 to test, the sum is supposed to stop at 15 because:1+2+3+4+5 = 15 but I got 17 I dont knw what im missing plz help
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Lalit MRank #1,186 · 1.5K reputationPosted Sep 1, 2011, 8:39 PM EDT
i=0,sum = 0;
while sum
sum = 0;
FOR i =0 and i <= sum
sum = sum +i
i++
END FOR
display (sum)
VulpesRank #55 · 29.2K reputationPosted Sep 2, 2011, 12:12 PM EDT