I have some pseudocode I am trying to analyze:
public static void test(float z) {
float y = 0;
for (float i = 1; i <= z; i++) {
if (y < z) {
y = 4 * i * i + 6;
}
}
return y;
}
From the function, I understand that y = 4i^2 + 6
whenever y < z
. However, I am having trouble capturing the relationship between y and z in an equation. I feel that it could be captured as a floor function (step function) -- for a certain range of numbers in z, y will have that specified value.
y
becomes greater than z
(and stops changing) for the first i
such that 2*i^2 + 3 > z
. In other words, a minimal i > sqrt((z - 3) / 2)
, which is floor(sqrt((z - 3)/2)) + 1
. Now as you know i
, compute y
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.