Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

WAP in Python to generate the following series upto 500. #1, 3, 6, 10, 15, 21,… 1+2=3,3+3=6,6+4=10,10+5=15

I want to increase i value by 1 every time I print A

n=1
m=3
A=m+3
i=4
for A in range(6,500,i):
  i+=1
  print (A,end=" ")

          

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This implementation works using a while loop:

A = 1
i = 1
while A <= 500:
    print (A, end=" ")
    i += 1
    A += i
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading