Recursion would go as well public static long factorial(int number) { if(number>=1) return number*factorial(number-1); else return 1; } and SysOut factorial(5);
//using while loop import java.util.Scanner; public class FactorialOfANumber { public static void main(String[] args) { System.out.println("Enter a number :"); Scanner sc=new Scanner(System.in); int num; num=sc.nextInt(); int number=num; int res=1; while (num>0) { res=res*num; num--; } System.out.println("Factorial of "+number+" is: "+res); } }
Thanks sir a lot...really liked the series..please make array set of questions as well. Thanks
Coming soon.
thank you so much , ur videos means a lot
Recursion would go as well public static long factorial(int number) { if(number>=1) return number*factorial(number-1); else return 1; } and SysOut factorial(5);
//using while loop
import java.util.Scanner;
public class FactorialOfANumber {
public static void main(String[] args) {
System.out.println("Enter a number :");
Scanner sc=new Scanner(System.in);
int num;
num=sc.nextInt();
int number=num;
int res=1;
while (num>0)
{
res=res*num;
num--;
}
System.out.println("Factorial of "+number+" is: "+res);
}
}
very simple explanation...thaanks a lot sir
You are most welcome
Thank you sir
Welcome
Good explanation. But did not cover while loop
Find factorial of a big number using Big integer class..... because if we do using int for big numbers it will stack overflow
Wonderful ❤️
Thank you!
Very nice
Thankyou Sir
Could have explained recursive solution as well. Mostly interviewers look for that.
Sir, Debugging video pls.
Sir reversing number lo scanner.ani yenduku vachhindi bro
Sir Make an video about ISTQB Fundamental level certification Details and How to prepare for it
How to remove the debug point?
Sir thank you God is great Sir op promote us also please in community's post
sir you look like harshad mehtaa 😳
public class Main
{
public static void main(String[] args) {
int num=5;
long fact=1;
while(num!=0){
for(int i=1;i
Write your print out statement outside the while loop
🇮🇳🇮🇳🙏🙏👍👍