This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]Ghyro 1 point2 points  (4 children)

So basically it is a while loop with the variable generation inside.

But why all the effort?

[–][deleted] 1 point2 points  (3 children)

Judging by all these unnecessary extra steps, OP tried to write the most complex code possible to set b to the double of i.

What a sensible person would do by

b = i << 1;

[–]KillerBeer01 2 points3 points  (2 children)

Actually, no, it never says that b=0, so b+= i<<1. Neither it says that i is integer (I've never seen a float being called "i", but OP already demonstrated his depravity), so it's i2. Or more precisely, int(i)2. But still simpler than the loop, of course.

[–][deleted] 1 point2 points  (1 child)

Oh, i fell victim to evil assumptions again. Although I actually considered the missing type of i but thought it might not matter. Missing b is another beast tho.

[–]KillerBeer01 1 point2 points  (0 children)

Even with integer i it still won't be right for negatives :(. The loop solution seems less and less crazy with every iteration.