Can loops like this one be algorithmically transformed into multiplication
문제
Are there known techniques for converting a loop like the following to an if
and a multiplication?
while (x < 0) {
x += 60;
}
It seems clear that this could be replaced with something like the following
if (x < 0) {
x += f(x, 60);
}
where f
contains no loops, presumably using multiplication. This would have the benefit of being faster for sufficiently large negative numbers.
Is there a well understood algorithm for finding f
for an arbitrary loop of this form?
올바른 솔루션이 없습니다
제휴하지 않습니다 cs.stackexchange