Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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)
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.
actually my algorithm is little bit slower compare to yours because the run time of my algorithm is O(9*n). n is the length of the string.
Algorigthm excludes sequence begining with 0 (like "05674") because it is not 5 digit number.
Great idea!