Hello Programmers/Coders, Today we are going to share solutions of Programming problems of 30 Days Of Code, HackerRank. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.
In this post, you will find the solution for Day 9: Recursion 3 in Java-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.
Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.
Link for the Problem – Day 9: Recursion 3– Hacker Rank Solution
Day 9: Recursion 3 – Hacker Rank Solution
Problem:
Objective
Today, we are learning about an algorithmic concept called recursion. Check out the Tutorial tab for learning materials and an instructional video.
Recursive Method for Calculating Factorial
Function Description
Complete the factorial function in the editor below. Be sure to use recursion.
factorial has the following paramter:
- int n: an integer
Returns
- int: the factorial of
Note: If you fail to use recursion or fail to name your recursive function factorial or Factorial, you will get a score of .
Input Format
A single integer, (the argument to pass to factorial).
Constraints
- Your submission must contain a recursive function named factorial.
Sample Input
3
Sample Output
6
Explanation
Consider the following steps. After the recursive calls from step 1 to 3, results are accumulated from step 3 to 1.
Day 9: Recursion 3 – Hacker Rank Solution
import java.util.Scanner; /** * @author Techno-RJ * */ public class Day9Recursion { public static int factorial(int i) { if (i == 1 || i == 0) { return 1; } else { return i * factorial(i - 1); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i = sc.nextInt(); System.out.println(factorial(i)); sc.close(); } }
Quality content is the key to attract the visitors to go to see the
web page, that’s what this web site is providing.
Aluminum packaging scrap Aluminium scrap customs clearance Aluminum scrap reclamation
Metal waste recovery and repurposing Clean aluminium scrap Aluminium scrap export-import trends
Metal scrap collection, Aluminum cable, Scrap metal recovery depot
Metal repurposing Aluminium alloy recovery Aluminium scrap waste elimination
Ethical metal sourcing, Aluminum cable scrap transportation, Metal waste repurposing center
Metal waste reprocessing plant Scrap aluminium reuse Aluminium recycling chain
Scrap metal handling solutions, Aluminum cable scrap alloys, Scrap metal reclamation
Metal recovery plant Aluminum scrap for automotive industry Aluminium scrap streaming
Metal reprocessing and reclaiming, Scrap aluminum cable disposal methods, Metal scraps reclamation facility
Metal recovery and reclaiming solutions Aluminium scrap resources Aluminum recycling plant operations
Metal repurposing services, Aluminum cable scrap grading, Scrap collection network
Metal waste recycler Aluminium scrap pricing Aluminium alloy separation
Metal recovery yard services, Buying aluminum cable, Scrap metal reclamation and recovery services
Metal reclamation depot Metal recycling industry Iron recovery center
Ferrous metal recycling challenges, Iron scrap refining services, Scrap metal reprocessing plant
Precious metal extraction Ferrous material grading services Scrap iron trade
Ferrous metal processing center, Scrap iron reclaiming yard, Metal reprocessing depot
Scrap metal brokers Ferrous material data management Iron scrap collection points
Ferrous scrap refinishing, Scrap iron reclaiming services, Metal reclaiming and utilization center
Scrap metal recovery and reprocessing Ferrous metal market Iron scrap resale
Ferrous material recycling handling, Iron waste reclamation facilities, Metal recovery and salvage
Metal recycling supply Ferrous material alloy Scrap iron recovery facility
Ferrous material safety protocols, Iron scrap regain, Metal reclaiming and reutilization services