You are essentially just doubling the X value so a simple for loop should do. Something like this Code: int $i; float $x = 0.005; for($i = 0; $i < $numberOfCVs; $i++) { $x *= 2; // Do whatever needs to be done }