What is wrong in this code

it is not giving same output and i am not able to know how to count digits
I am also not able to solve all the problems i don’t know what to do…???

you can use while loop to check the number of elements printed in series
modified code

in this code does i represent the count that we have printed ???

i represents the index of x in the series i.e if i is 1 then x is first element in the series.