hi what do they mean by while(n>1) { if (n is even) n:=n/2 else n:=3*n+1 }
@Opcode
while (n > 1){ (n is even) n : n /2 else n :=3*n+1 }
@Hero
@ZeHanz
actually i want to know :=
If you have a number n that is larger than 1, do the following: As long it is even (i.e. it has at least one factor 2), then divide it by 2. So all factors 2 are divided out. After this, and if this n without any factors 2 is still larger than 1, multiply it with 3 and add 1. Let's try a number, say n=20 (=2*2*5) The two factors 2 are removed, leaving n=5. Now this becomes 16. (3*5+1). Another number: n=2*2*2*3*5=120. This is converted to 15. Then it becomes 46. I have no idea what is the use for this...
n is assigned to
C derived languages use = to assign, and == to compare. Pascal derived languages use := for assignment and = for comparison.
Join our real-time social learning platform and learn together with your friends!