suma n/((n+1)(n+2)

//1/(2*3)+2/(3*4)+…(n/((n+1)(n+2))
#include<iostream.h>
#include<conio.h>

float e(int k)
{
return (float)k/((k+1)*(k+2));
}

float s(int k)
{
if
(k==1) return (float)1/(2*3);
else return e(k)+s(k-1);
}

void main()
{
int n;
cout<<“n=”;cin>>n;
cout<<s(n)<<endl;
getch();
}

{module orizontal600}

combinari

//combinari
#include<iostream.h>
#include<conio.h>

long comb(int n,int k)
{
if (k==0)  return 1;
else if (k>n) return 0;
else return (comb(n-1,k)+comb(n-1,k-1));
}

void main()
{
int k,n;
cout<<“n=”;cin>>n;
cout<<“k=”;cin>>k;
cout<<//”combinari de”<<n<<“elemente luate cate”<<k<<“:”<<
comb(n,k)<<endl;
getch();
}

{module orizontal600}

suma a n componente

//sa se calculeze suma componentelor unui vector cu  n elemente
#include<iostream.h>
#include<conio.h>
typedef int vector[20];
int n;vector v;

int suma(vector v,int n)
{
if (n==0) return 0;
else return (v[n]+suma(v,n-1));
}

void main()
{
int i;
cout<<“n=”;cin>>n;
for(i=1;i<=n;i++) {cout<<“v[“<<i<<“]=”;cin>>v[i];}
cout<<“suma este”<<suma(v,n)<<endl;
getch();
}

{module orizontal600}