Răspuns :
#include <iostream>
using namespace std;
int suma(int n)
{
if(n == 1) return 0;
if(n == 2) return 2;
return 3 + suma(n - 1);
}
int main()
{
int n;
cin>>n;
cout<<suma(n);
}
using namespace std;
int suma(int n)
{
if(n == 1) return 0;
if(n == 2) return 2;
return 3 + suma(n - 1);
}
int main()
{
int n;
cin>>n;
cout<<suma(n);
}
var n:integer;
function suma(n:integer):integer;
begin
if (n=1) then suma:=0 else
begin
if (n=2) then suma:=2
else suma:=3+suma(n-1);
end;
end;
begin
read(n);
write(suma(n));
end.
function suma(n:integer):integer;
begin
if (n=1) then suma:=0 else
begin
if (n=2) then suma:=2
else suma:=3+suma(n-1);
end;
end;
begin
read(n);
write(suma(n));
end.