0

There is some code snippet written on python:

number = 5602004
accum = 0
while number:
    accum += (3 * (number % 10))
    number = int(number / 10)
    accum += (number % 10)
    number = int(number / 10)

So, cycle is working while variable number greater then 0. The question is: can this cycle be presented as math formula?

  • 1
    What is pin? What is accum initialised to? – Patrick Stevens Feb 17 '17 at 22:19
  • Programmers typically call such a control structure a loop rather than a cycle. It would help Readers if you were a bit clearer about what you want the math formula to represent. For example, your snippet tells us nothing about how pin and number are initialized/declared. – hardmath Feb 17 '17 at 22:20
  • Sorry my fault I have edited code, pin was a wrong variable @PatrickStevens. Initially accum equals to 0. and number initially for example can be equal to 5602004. When number = 0, we should save last result of variable accum – Roman Banakh Feb 17 '17 at 22:31