Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- float Q(int n)
- {
- float i , res = 0 ;
- for (i = 1 ; i <= n ; i++) res += 1 / (i * i) ;
- return (res) ;
- }
- float A(int n)
- {
- float res , prod1 , prod2 ;
- int i , j ;
- for (res = 0 , i = 1 ; i <= n ; i++)
- {
- for (j = 1 , prod1 = -1 ; j <= i ; j++) prod1 *= -1 ;
- for (j = 1 , prod2 = 1 ; j <= i ; j++) prod2 *= 2 ;
- res += prod1 * (1 / prod2) ;
- }
- return (res) ;
- }
- int main()
- {
- int n ;
- printf ("Indique o valor de N: ") ;
- scanf ("%d" , &n) ;
- printf ("Q(%d)=%.2f e A(%d)=%.4f\n" , n , Q(n) , n , A(n)) ;
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment