Which of the following is the base case for a recursive factorial function?पुनरावर्ती फैक्टरियल फ़ंक्शन के लिए निम्नलिखित में से कौन सा आधार मामला है?
पुनरावर्ती फैक्टरियल फ़ंक्शन के लिए निम्नलिखित में से कौन सा आधार मामला है?
Show answerHide answer
Correct answer: (B) n == 1n == 1
Explanation
The key takes n == 1 as the base case, returning 1 and ending the recursion. Many implementations use n == 0 (or n <= 1) instead, since 0! = 1 as well.कुंजी n == 1 को base case मानती है, जो 1 लौटाकर रिकर्शन समाप्त करता है। कई कार्यान्वयन n == 0 (या n <= 1) लेते हैं, क्योंकि 0! = 1 भी है।