Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double funkcija(int n) {
- double result = 0.5;
- int brojac = 1;
- for(int i = 3; i <= n; i += 2) {
- if(brojac % 2 == 0) {
- result /= ( (double)i / (double)(i + 1) );
- }
- else {
- result *= ( (double)i / (double)(i + 1) );
- }
- brojac++;
- }
- return result;
- }
- int main (int argc, const char * argv[]) {
- int n;
- scanf("%d", &n);
- printf("%lf\n", funkcija(n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement