Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /*
- NOTA: pot_rec feito no exercicio 3
- */
- // - 4
- float som(int n, float r,float fact=1,float exp=1,int i=1)
- {
- fact*=i;
- exp*=r;
- if(n==i)
- return exp/fact;
- return exp/fact + som(n,r,fact,exp,i+1);//++i
- }
- /*float som2(float r, int i)
- {
- if(i==1)
- return r;
- return pot_rec(i,r)/fat_rec(i) + som2(r,i-1);
- }*/
- // - 5
- /*float soma(int n, float fat=1, i=1)
- {
- fat*=i;
- if(i==n)
- return pot_rec(i,fat);
- return pot_rec(i,fat) + soma(n,fat,i+1);
- }*/
- float soma2(int i, float fat=1)
- {
- fat*=i;
- if(i==1)
- return 1;
- return pot_rec(i,fat) + soma(n,fat,i-1);
- }
- void main ()
- {
- //4
- float r;
- int n;
- printf("Introduza o valor de N");
- scanf("%d",&n);
- printf("introduza o r: ");
- scanf("%f",&r);
- printf("Resposta: %f", som(n,r));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement