Factorial Calculator

--Originally published at Regular Blog

factorial calculator100r

FACTORIAL:
“El resultado de multiplicar una serie de números naturales en orden descendente, como 4, 3, 2, 1.

Su símbolo es “!”

Ejemplos:

4! = 4 × 3 × 2 × 1 = 24
7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5040″
–Recuperado de: https://www.disfrutalasmatematicas.com/definiciones/factorial.html

In this assignment I used “” cher “”, que es para crear una variable de texto, la cual utilicé al momento de preguntarle al usuario si deseaba continuar.

Para la parte de calcular el factorial del número que nos da el usuario, utilicé el siguiente loop…

y=1;
while(x>1){
y=y*x;
x=x-1;

–> Antes del loop se aclara que a Y se le asigna el valor de 1. En el loop… mientras X sea mayor a 1, se multiplicará Y (1) por X (el valor que le asignó el usuario), y al final se le restará 1 a X, para que cuando se repita el loop, Y se multiplique por un número cada vez menor a partir del primer valor que le asignó el usuario.

Al final, después de preguntar al usuario si desea continuar, usé el siguiente loop…

while (a==’s’);
cout<<"Te deseo suerte en este mundo de pecados y pecadores"<Donde si el usuario responde cualquier cosa que no sea ‘s’, le deseará suerte y se terminará el programa.

DogCalculatorCr


WSQ 06…

--Originally published at tc1017 – chivas4ever2009

This program seemed to be more difficult, but it was not. It consisted in programming a factorial calculator, the user should introduce any value and the program will provide the factorial of that number. The first thing I had to do was understand what was the mathematical term for ‘factorial’. Then I searched in google for tutorials, I found two different forms of doing it, but I was confused and didn’t understand at all. Then Ken explained that specific program in class because some of us were having problems. So with that and with the research I had done, I could develop my code and it worked.

**IMPORTANT STUFF**
+Sharing questions at class, because there can be times when other students have the same questions and also everyone can learn something new from the questions.

Links of my research:

http://es.ccm.net/forum/affich-1284727-sacar-el-factorial-de-un-numero-con-c

https://www3.ntu.edu.sg/home/ehchua/programming/howto/EclipseCpp_HowTo.html

2017-09-15 (3)


WSQ 06! FACTORIAL CALCULATOR!

--Originally published at Ervin Schlamme´s blog

In this #wsq06 we are going to learn how to create a factorial calculator. First of all we need to know what is a factoria operation (n!), which is the product of every number in a sequence in which n+1 is achieved. For example:

5!=1*2*3*4*5=120

The code for this operation is this one:

#include <iostream>
#include <string>
using namespace std;

 

int factorial (int n) // create a function of type integer that give the factorial value of n (n!)
{
if (n == 0)
{
return 1;
}
else
{
int recursion = factorial (n – 1);
int answer = n * recursion;
return answer;
}
}

 

int main ()
{
repeat:
string again;

int number;
int answer;
cout << “type number” << endl;
cin >> number;
answer = factorial (number);
cout << “The value for n! = ” << answer << endl; // prints the answer

 

ask:
cout << “Do yu want to try again?” << endl;
cin >> again;

if (again == “yes”) goto repeat;
if (again == “no”)
{
cout << “Come back soon!” << endl;
}
else
{
cout << “That is not a valid answer, try again simply typing yes or no.” << endl;
goto ask;
}

return 0;
}

in which the result must be like this:Factorial number

I made a correction on “come back soon” on the code I just showed, in the image it says “Come back soos!”.

Oh, and by the way I used the next #masterytopics:

#masterytopics25

#masterytopics26

#masterytopics27

#masterytopics10

#masterytopics06

#masterytopics07


Factorial calculator

--Originally published at Valeria CT

For this assignment I tried different types of loops until I found out how to use a goto command and found that it was really helpful. I finally used a string and discovered that I had to include a special library for it.

Here is the link to my program: https://github.com/valeriact/tc1017/blob/master/wsq06.cpp

And the resources that I used:

 

-Valeria


WSQ 06 – Factorial

--Originally published at Solving problems with programming

For these final algorithm was some difficult for me because i have never see the topic in the book or class, but my little friend mariel help out with her code and a little but great explanation.

This is my github link: https://gist.github.com/jesuscmadrigal/2466048b4a0ec5ec0dd459fb9b86a13b

Haga click para ver el pase de diapositivas.