Answer to Question #278279 in Python for Mahesh

Question #278279

Write a simple python program to print and add number starting 1 onward till the sum of them is less than 100



#the required output is as the n positive number having the total sum less than 100 are .



1 2 3 4 5 6 7 8 9 10 11 12 13 sum of the numbers =91




1
Expert's answer
2021-12-10T13:22:53-0500
s = 0
n = 1
while True:
	s += n
	if s > 100:
		break
	else:
		print(n, end=' ')
	n += 1

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS