if the variable is m how the while loop can compute sum of squre of first five continuing numbers.how it can associate the sum with total
compute the sum of squres
Collapse
X
-
Please post what you have tried on that and be a little more specific.Originally posted by eaner51if the variable is m how the while loop can compute sum of squre of first five continuing numbers.how it can associate the sum with total -
You may want something like this:[CODE=python]Originally posted by eaner51if the variable is m how the while loop can compute sum of squre of first five continuing numbers.how it can associate the sum with total
>>> sumofsqs = 0
>>> i = 0
>>> while i < 5:
... i += 1
... sumofsqs += i*i
...
>>> print sumofsqs
55
>>> [/CODE]
Please note the use of CODE tags. Instructions are on the right hand side of the page while you are posting. Thanks.Last edited by bartonc; Oct 21 '07, 07:46 PM.Comment
Comment