Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Freshman in programming, HELP PLS!!!

–1 vote
asked Dec 21, 2018 by freshman

Make a recursive description of the f (x) function formulated below. (x will be considered to be an integer.)

f(x) = 1 , x<=1 x + f(x-1) , x > 1

(Please explain how did you solve.)

2 Answers

0 votes
answered Jan 1, 2019 by Admin (4,420 points)
It seems formulated function doesn't explain what should be the value for x>1
+2 votes
answered Jan 8, 2019 by Akanksha Varshney (180 points) 1 flag
#include <stdio.h>
int main()
{int x;
   printf("Enter an integer");
   scanf("%d", &x);
   printf("The output of the function is %d", f(x));
}
int f(int x)
{
    if(x>1)
    return x+f(x-1);
    else
    return 1;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...