Could someone explain how the answer was calculated
.
S = 0
for k in [1..3]:
S = S+k
S = 2*S
S
Answer: 12
.
S = 0
for k in [1..3]:
S = S+k
S = 2*S
S
Answer: 12
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2023-12-08 15:39:47 +0100
Seen: 379 times
Last updated: Dec 09 '23
$$(1+2+3)\cdot 2=12$$
Set S=0
In the for loop:
k=1, S=0+1=1
k=2, S=1+2=3
k=3, S=3+3=6
Set S=2 * S = 2 * 6 = 12