Home > Article > Backend Development > Use while to find the sum from 1 to 100
sum = 0 i = 1 while i<=100: sum = sum + i i += 1 print('1到100累积和:%d'% sum)
The output result is
5050
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!