What is the most efficient way to calculate the factorial of a number?

AnswerBot
1y

The best and less time consuming way to calculate factorial of a number is using iterative approach.

  • Iteratively multiply the number with all the numbers from 1 to the given number

  • Start with a result v...read more

Amruta Kawale
5y

#include<stdio.h>

void main()

{

int n,i,fact=1;

printf("enter the number");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

fact=fact*(n-1);

n--;

}

}

ASHISH KUMAR YADAV
7y

public class Recursion{

static int factorial(int n){

if(n==1)

return 1;

else

return (n*factorial(n-1));

}

public static void main(String []args){

System.out.println("factorial of 5="+factorial(5))...read more

Vivek Kumar
7y

#include<stdio.h>

#include<conio.h>

void main()

{

int i,n,f=1;

printf("Enter A Number To Find Factorial: ");

scanf("%d",&n)

while(n>=0)

{

f=n*f;

n--;

}

Select
Add answer anonymously...

PTC Software Developer interview questions & answers

A Software Developer was asked Q. What is a real-time example of polymorphism?
A Software Developer was asked Q. Is multiple inheritance allowed in Java?
A Software Developer was asked Q. What is inheritance?

Popular interview questions of Software Developer

A Software Developer was asked Q1. What is a real-time example of polymorphism?
A Software Developer was asked Q2. Is multiple inheritance allowed in Java?
A Software Developer was asked Q3. What is inheritance?
PTC Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits