Method 1 (FOR)
STEP 1. Set I <-- 0, N <-- 0, Sum <-- 0
Method 2(WHILE)
STEP 1. Set I <-- 0, N <-- 0, Sum <-- 0
STEP 2.
Read
N
STEP 3.
Repeat
for I = 0, 1, … N – 1
Begin
Sum <--
Sum + I
End
STEP 4.
Print
SumMethod 2(WHILE)
STEP 1.
Set I <-- 0, N <-- 0, Sum <-- 0
STEP 2.
Read N
STEP 3.
while (I<=N-1)
Begin
Sum <--
Sum + I
I<-- I+1
End
STEP 4.
Print Sum
it's fucking easy!
ReplyDelete