Skip to content

Sum of evens

Pascal evens up to n

Same task in: Rust

Flowchart (ISO 5807)

YesNoStartInput ns = 0i = 1, n, 1i mod 2 = 0s = s + isumEven = sEndFigure 1 — sumEven

Source code

Pascal
function sumEven(n: integer): integer;
var i, s: integer;
begin
  s := 0;
  for i := 1 to n do
    if i mod 2 = 0 then
      s := s + i;
  sumEven := s;
end;

The editor opens with this code — change it and the chart redraws.

Language
Pascal
Constructs
evens up to n
Topic
Loops
Formats
Word, Visio, draw.io, PDF, SVG

Related examples