Kites Garbkites.hashnode.dev·Aug 26, 2024Generate factorialdef factorial(n): if n == 0: return 1 else: return n * factorial(n-1) # Example usage print(factorial(5)) # Output: 120DiscussFactorial
Bhuwan Sharmabhuwan.hashnode.dev·Jun 3, 2024#7 Functions#include<iostream> using namespace std; // Note: uncomment the code you want to use. // Power of a number: // int power(int a, int b){ // int ans = 1; // for (int i=1; i<=b; i++){ // ans*=a; // } // return ans; // } //___...DiscussDSA
SUDHIR PATELsudhircyber.hashnode.dev·May 18, 2024Simple Java Interface Code Examples//HERE IN THIS CODE WE IMPLEMENT AN INTERFACE JAVA CODE FOR FACTORIAL AND EVENODD NUMBER CHECK ... \===============SO THE CODE IS GIVEN BELOW====================== //The first interface in myfirstpr "package"--- package myfirstpr; public interface I...Discussjava factorial code
Gagan G Saralayagagang.hashnode.dev·Mar 6, 2024C program to find the factorial of a number.Here is a program to find the factorial of a number. #include<stdio.h> int fac(int n); int main() { printf("Here is a program to find the factorial of a number using functions\n"); printf("Enter a num to find the factorial:"); int n = 0...Discusscrazyblogger
Jyotiprakash Mishrablog.jyotiprakash.org·Dec 27, 2023Recursion can make your head spin!Recursion is a programming concept where a function calls itself to solve a problem. To help you understand recursion in C, let's go through a simple example: calculating the factorial of a number. The factorial of a non-negative integer (n), denoted...DiscussC ProgrammingRecursion
RuchikaRawaniruchikarawani.hashnode.dev·Nov 26, 2023A Beginner's Guide to Recursion: Understanding Factorials in C++Welcome to the world of programming! If you're just starting your coding journey, you may encounter terms like "recursion" that sound complex at first. Fear not! In this blog post, we'll explore a simple C++ code snippet that calculates factorials us...DiscussRecursion
Sirisha Challagirisirishachallagiri.hashnode.dev·Nov 15, 2023Factorial of a numberFactorial of a non-negative number is the multiplication of all positive numbers that are smaller than are equal to n. Formula: n! = n*(n-1)\(n-2)*... 2\1 n=5 => 5*4*3*2*1 n=5 => 1*2*3*4*5 factorial of 5 is 120 0! = 1 Factorial using for loop: public...Discuss·1 likeCode With SiriJava
Sawan Badhwarsawan1367.hashnode.dev·Oct 31, 2023Recursion ProblemsHello everyone, I hope that you all are doing great and being wary of the weather changes. So, today it's my day 4 since my 100-day DSA challenge began. Till now we discussed a few things like time complexity, space complexity and recursion. But I do...Discuss·1 likeRecursion in programming
Corina Murgcorina.hashnode.dev·Aug 29, 2023Memoization and the Magic of Self-Containing FunctionsIn JavaScript development, caching data for quick retrieval is paramount. Many developers instinctively reach for objects as key-value stores or arrays for ordered lists. Some might even delve into specialized data structures like Maps and Sets to op...DiscussQuirks of JavaScriptMemoization
Anushayosa.hashnode.dev·Aug 16, 2023Function PointerThis blog has a program that uses Function Pointer to perform two different operations. I split the code into smaller sections and explain. The standard input output header file is included to print to the stdout. #include <stdio.h> This function ca...DiscussC basicsC