Advertisement
vencinachev

UFunction

Mar 26th, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. double calculateU(int);
  6.  
  7. int main()
  8. {
  9.     int n;
  10.     double u;
  11.     printf("Enter n: ");
  12.     scanf("%d", &n);
  13.     u = calculateU(n);
  14.     printf("U(%d) = %f\n", n, u);
  15.     return 0;
  16. }
  17.  
  18. double calculateU(int n)
  19. {
  20.     int i;
  21.     double u = 1;
  22.     for (i = 1; i <= n; i++)
  23.     {
  24.         u = 2 * sqrt(u + 1) - 1;
  25.     }
  26.     return u;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement