Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double func(double x, int n)
- {
- if (n < 0)
- {
- return (1/x) * func(x, ++n);
- }
- if (n > 0)
- {
- return x * func(x, --n);
- }
- return 1;
- }
- int main ()
- {
- printf("%.0lf\n", func(10, 2));
- printf("%lf\n", func(10, -2));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement