#WSQ06 Factorial Calculator 12/02/17 and WSQ06.cpp

--Originally published at Solving Problems with Programming

Link of the picture: Link of the picture

So in this seven week class I started with doing the Computing for Social Good!!! and this WSQ06. Therefore, I started reviewing in creating and calling functions in C++. #Mastery06, #Mastery07, #Mastery16 Use of recursion for repetitive algorithms and #Mastery17 When to use what type of repetition in a program

What I did for this numeric program is solving the problem to the user by writing a program that asks the user for a non-negative integer (let’s call that number n) and display for them the value of n! (n factorial).

After showing them the answer, ask them if they would like to try another number (with a simple Y/N response) and either ask again (for Y) or quit the program and wish them a nice day (if they answered N).

Moreover, you need to have  two basic approaches: a loop with an accumulator of the multiplication and a recursive solution. Choose one and implement that. Once that is done, try the other way.

If you used a while loop for the solution with a loop, try structuring this with a for loop (or vice-versa). Therefore, I am going to show you the 2 solutions in order to accomplish the the masteries regarding recursion. #Mastery16 and #Mastery17

The resources I need it to solve this program with the loop algorithm are here:

Similar code made by Xochitl96

The resources I need it to solve this program with the recursion solution and accomplish #Mastery16 Use of recursion for repetitive algorithms an #Mastery17 When to use what type of repetition in a program are here:

Similar code made by Gonzalomata22

The following photograph shows the solution to this problem:

Picture of author

So at first I wrote the same structure of the program just did the same as what

11
12
13
14
fact
30
31
32
33
Continue reading "#WSQ06 Factorial Calculator 12/02/17 and WSQ06.cpp"

Homework 6: Factorial Calculator

--Originally published at Let's CODE

Let’s make a factorial calculator! First of all, we have to know what a factorial number is. If you see a number that is accompanied by an exclamation sign, you’re seing a factorial number, that consists in a number multiplied by all the precedent integer numbers until reach one. For example, 6!= 65432*1 = 720. … Continue reading Homework 6: Factorial Calculator

WSQ06-Factorial and the delusion of the exclamation mark.

--Originally published at The Talking Chalk

In math, you can represent a factorial number as n! but in c++ you cannot just type a ! following a number to get its factorial, as ! is mostly used to express that something is not something (as in !=).

I decided to still use a do and while number as I did not comprehended completely” the for” loops.

The main problem was to have a proper way to express the formula of a factorial number with conditionals and loops. I had to replace int variables in a loop so they could grew bigger until they reached the number the user asked for. Hading a counter, the factorial, and the multiply which would be the factorial of that try of the loop is what made it succesful.

So, if you were not related with the “for” (which you should be) or want to know another form to get a factorial number in c++. follow this technique.

#include <iostream>
using namespace std;
int main()
{
int value, factorial, count=1, multiply=1;
do
{
cout<<“Could you give an integer positive number, please?”<<endl;
cin>>value;
}
while(value<=0);
if(value>1)
{
do
{
factorial = (multiply)*(count+1);
multiply = factorial;
count = count+1;
}
while(count<value);
}
else{
cout<<“The factorial of this number is 1.”<<endl;
}
cout<<“The factorial of this number is “<<factorial<<“.”<<endl;
}

WSQ06

--Originally published at TC1017

Want a factorial for a number? But today is your lucky day, with this awesome program you get to choose which number you get the factorial, and if you’re bored with the program IT WISHES YOU A NICE DAY!! how cool is that!.

#BAPL

Link to the code: https://docs.google.com/document/d/1ZchDTp6m4T0hVMTrAV1V6PCLf-6Z10RabBwppqjjFEI/edit?usp=sharing


Factorial

--Originally published at Ken&#039;s Disciple 01

Picture by Unsplash Unsplash

 

In this Blog i’ll talk about WSQ06, where we had to do a program that asked the user for a number, and we would show it’s factorial value. Also we had to ask if the user wanted to give us another number or if he wanted to exit we had to wish him a nice day.

As you can see in my code, it was pretty easy since we had to use things we already knew, we had o use a do-while function and a for function. Everything is easy but in order to make our program work we have to pay attention to some points:

  • We have to declare a char variable at the beginning, which will be the response to our question of the do-while function: Would you like to try another number?, it has to be at the beginning because it has to be before our do-while function.
  • The second important thing to know is that INSIDE our -do while, we had to declare to int variables, one that is the number that the user will provide, and another that will be its factorial value. It has to be inside because once we ask if the user wants to try again, the variables must erase their last value to their inicial value which is 0 and 1, if we don’t do this the values would be adding to the last values. the value of the number of the user can be whatever you want, because later it’ll be overwritten with the value of the user, and the value of our factorial has to be 1 in order to do the operations of the for function correctly (also it gives 0 its factorial number of 1).

Here’s my code so you can

Captura de pantalla 2017-02-11 a la(s) 13.32.24.png
Captura de pantalla 2017-02-11 a la(s) 13.32.58.png
Continue reading "Factorial"

Yo por Yo, por Yo, por Yo…

--Originally published at Adal´s Blog

La actividad esta así:


Básicamente consiste en hacer un programa que nos permita calcular el factorial de cualquier número que le introduzcamos, es decir que hay que multiplicar todos los números enteros positivos que hay entre ese número y el 1.  

En el libro de la clase thinkCScpp, viene un ejemplo, el cual solamente lo voy a adaptar al código


Libro de ayuda:
  • thinkCScpp

WSQ06 – Factorial Calculator

--Originally published at Programming the city

Today, I created a program where the user gives me a number and I calculate its factorial.

Now Im making every code with functions.

The only thing I used was a for and a loop, to ask the user if he or she wants to keep the program running or if he/she wants to get out of there.

Just for advice, becareful in where you type the {} the position matters a lot.


wsq06-1wsq06-1


And the result is

wsq06-1

 

I want to say thanks to my classmates and the people that helped me without realizing, like this two web pages:

 

https://www.trucoswindows.net/forowindows/temas/variable-a-usar-para-texto-c.52540/