Questions tagged as 'fatorial'

4
answers

Best algorithm to calculate factorial

So, I'm learning to develop in Java. The teacher asked me to develop a method for the Factorial. And also show what is happening on the screen, for example: 3! = 3 X 2 X 1 = 6 In fact, I made it happen, but is there any way for the code...
asked by 02.09.2016 / 00:35
1
answer

My factorial function does not return the expected value! C language

My teacher is starting to go through functions, and asked us to do a factorial function of a number, but it always returns the wrong value and I do not know what happens. Code: int fatorial(int n) { int ans = 1; while(n>1){ ans*=n;...
asked by 26.08.2018 / 18:39
2
answers

Hiperfatorial in C by recursion

I'm trying to make a program with a recursive function to return a hyper-factor from a number in C, but the only value the function returns is 1. Where am I going wrong? #include <math.h> #include <stdio.h> #include <stdlib.h>...
asked by 16.11.2017 / 19:24
2
answers

Write each step of calculating a factorial

I have a piece of code that calculates the factorial of a number in JavaScript, but I wanted it to return the steps of each calculation, eg:    3! = 1x2x3 = 6 Follow the code I made. I tried to "print" decrementing the variable, but I'm n...
asked by 31.05.2018 / 06:10
3
answers

Make PHP print the result of the Factorial class

<?php class Fatorial { function calcular(){ $fat = $_GET['fat']; $resultado = 1; for($i = $fat; $i >= 1; $i--){ $resultado *= $fat; $fat--;...
asked by 22.05.2017 / 01:55
1
answer

n = 1 in the while condition returns no value

Good evening. I'm starting to learn java and did a swing program that calculates the factorial of a number. I did using while, and in the condition, I tried to do with the condition (n >= 1) (I'll put the code snippet below), and th...
asked by 10.01.2017 / 00:55
2
answers

Factorial in python, [closed]

People, I'm new in the programming area, and doing exercises I came across the following question: Make a program that calculates the factorial of a user-supplied integer. Ex.: 5!=5.4.3.2.1=120 How do I use pycharm to solve...
asked by 22.10.2016 / 06:06
1
answer

Strange results when calculating factorial [duplicate]

I can not seem to find the error in my code. When I put numbers smaller or equal to 12 my program gives the right result, but from number 13 the values go out wrong and I can not know why. What is wrong? class vdois { static int fatoria...
asked by 06.05.2017 / 20:42
1
answer

How to factor n! or

How to factor a number? n! or! n Example: Let's take x = 5 x = input('Digite um número inteiro: ') i = 1 while i <= x: for i in range(x): i = i + 1 a = [] a.append(i) print(a) break...
asked by 08.07.2017 / 21:38
1
answer

Python Replay Structure [closed]

I need to solve the following equation in Python    N is an integer and positive value. Calculate and show the value of E according to the following formula:       E = 1 + 1/1! + 1/2! + 1/3! + ... + 1 / N! My attempt: n = int(input("Di...
asked by 13.09.2017 / 17:00