Ad
  • Custom User Avatar

    Sorry,I dont understand, why do you divinate on pc in first equation?

    p1 = p0*(1+pc) + aug
    p2 = p1*(1+pc) + aug = (p0*(1+pc) + aug)(1+pc) + aug = p0(1+pc)^2 + aug*((1+pc) + 1)
    p3 = p2*(1+pc) + aug = (p0*(1+pc)^2 + aug*((1+pc) + 1)(1+pc) + aug =
    = p0
    (1+pc)3 + aug((1+pc)^2 + (1+pc)) + aug = p0*(1+pc)3 + aug((1+pc)^2 + (1+pc) + 1)
    .
    .
    .
    pN = p0*(1+pc)^N + aug*((1+pc)^(N-1) + (1+pc)^(N-2) + ... + (1+pc)^2 + (1+pc)^1 + (1+pc)^0)
    = p0*(1+pc)^N + aug*((1+pc)^N - 1)

  • Custom User Avatar

    This solution has a mistake!
    n is always overwritten to 10001.
    External cycle should be do/while due to fact that even if n is a number from 1 to 100,
    summ of it's digits should be counted and substracted from n.
    Although I have posted correct solution, I don't know how to revove incorrect one.

  • Custom User Avatar

    Algorigthm excludes sequence begining with 0 (like "05674") because it is not 5 digit number.
    Great idea!