Use while to find the sum from 1 to 100

silencement
Release: 2019-06-25 10:51:24
Original
55373 people have browsed it

Use while to find the sum from 1 to 100

sum = 0
i = 1
while i<=100:
    sum = sum + i
    i += 1
print(&#39;1到100累积和:%d&#39;% sum)
Copy after login

The output result is

5050
Copy after login

The above is the detailed content of Use while to find the sum from 1 to 100. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template