70 likes | 195 Views
FOR i := 0...N-1 DO summa := summa + A[i] tulo := tulo * A[i] ENDFOR. FOR i := 1 ... N DO FOR j:= 0 ... N-1 DO maara := maara + 1 ENDFOR ENDFOR. FOR i := 0 ... N DO A[i] := 0 ENDFOR FOR i := 0 ... N-1 DO FOR j:= 1 ... N DO A[i] := A[i] + j * i ENDFOR ENDFOR.
E N D
FOR i := 0...N-1 DO summa := summa + A[i] tulo := tulo * A[i] ENDFOR
FOR i := 1 ... N DO FOR j:= 0 ... N-1 DO maara := maara + 1 ENDFOR ENDFOR
FOR i := 0 ... N DO A[i] := 0 ENDFOR FOR i := 0 ... N-1 DO FOR j:= 1 ... N DO A[i] := A[i] + j * i ENDFOR ENDFOR
FOR i := 1 ... N DO IF i mod 2 = 0 THEN osam := i / 2 taulu[i] := osam ELSE taulu[i] := i ENDIF ENDFOR
MODULE kertoma (n) returns n:n kertoma IF n <= 1 THEN RETURN 1 ELSE RETURN n * kertoma(n-1) ENDIF ENDMODULE
MODULE haku(A[], x, N) RETURNS indeksi alku := 0 loppu := N-1 WHILE alku <= loppu DO keski := (alku + loppu) / 2 IF A[keski] < x THEN alku := keski + 1 ELSE IF A[keski] > x THEN loppu := keski – 1 ELSE RETURN keski ENDIF ENDIF ENDWHILE ENDMODULE
MODULE fib(N) RETURNS N:s fibonacci IF N <=1 THEN RETURN 1 ELSE RETURN fib(N-1) + fib(N-2) ENDIF ENDMODULE