0% found this document useful (0 votes)
5 views2 pages

While 3

The document contains three C++ programs that calculate different mathematical expressions. The first program computes the sum S=1*4+2*7+3*10+...+n*(3*n+1), the second calculates the product P=1*3*5*...*(2*n-1), and the third finds the sum of factorials up to n. Each program prompts the user for an integer n and outputs the result.

Uploaded by

Adriana Bugariu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

While 3

The document contains three C++ programs that calculate different mathematical expressions. The first program computes the sum S=1*4+2*7+3*10+...+n*(3*n+1), the second calculates the product P=1*3*5*...*(2*n-1), and the third finds the sum of factorials up to n. Each program prompts the user for an integer n and outputs the result.

Uploaded by

Adriana Bugariu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1)

#include <iostream>

using namespace std;


///Să se calculeze suma: S=1*4+2*7+3*10+..........+n*(3*n+1)
int main()
{
int n,i=1,s=0;
cout<<"n=";
cin>>n;
while(i<=n)
{
s=s+i*(3*i+1);
i++;
}
cout<<"suma e "<<s;

return 0;
}

2)
#include <iostream>

using namespace std;


///Să se calculeze produsul: P=1*3*5*..........*(2*n-1)
int main()
{
int n,i=1,p=1;
cout<<"n=";
cin>>n;
while(i<=n)
{
p=p*(i*2-1);
i++;
}
cout<<"produsul e "<<p;
return 0;
}

3)
#include <iostream>

using namespace std;


///Să se calculeze suma: S=1+1*2+1*2*3+1*2*3*4+. . . .+1*2*. . . .*n.
int main()
{
int n,s=0,i=1,p=1;
cout<<"n=";
cin>>n;
while(i<=n)
{
s=s+p;
i++;
p=p*i;
}
cout<<"suma e "<<s;
return 0;
}

You might also like