Răspuns :
Pascal:
Var
i,j,n,s,k:longint;
Begin
write('Dati n: ');readln(n);
For i:=2 to n do
Begin
k:=1;
For j:=2 to i div 2 do
if i mod j = 0 then k:=0;
if k=1 then s:=s+i;
End;
writeln('Suma numerelor pare = ',s);
End.
C++
#include<iostream>
using namespace std;
int main()
{
int n, i, suma=0;
cout<<"n=";cin>>n;
for(i=2;i<=n;i++)
if(i%2==0) suma=suma+i;
cout<<"Suma numerelor pare pana la "<<n<<" este "<<suma;
}