I found the mistake! In the ceil(), I was dividing a variable which contains the value of loopindex, which starts from 0.
ex) ceil(Variable_of_loopindex/n)
So this became ceil(0/20) = 0, while I was thinking it should be ceil(1/20) = 0.05.
Simple mistake caused by being unfamiliar with 0-based index!