From 54a12676d8917d45b4976283aa52acc1e7443b01 Mon Sep 17 00:00:00 2001 From: Tomas Gonzalez Date: Thu, 16 Dec 2021 18:42:34 +0000 Subject: [PATCH 1/3] Issue #556 fixed --- exercises/21-factorial/README.es.md | 7 ++++--- exercises/21-factorial/README.md | 10 +++++----- exercises/21-factorial/app.py | 2 +- exercises/21-factorial/test.py | 31 +++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 exercises/21-factorial/test.py diff --git a/exercises/21-factorial/README.es.md b/exercises/21-factorial/README.es.md index c1391272..b6f72b61 100644 --- a/exercises/21-factorial/README.es.md +++ b/exercises/21-factorial/README.es.md @@ -2,8 +2,9 @@ ## 📝 Instrucciones -Escribe un programa que puede calcular el factorial de un número dado. -Los resultados deberían imprimirse en una secuencia separada por coma en una sola línea. Supongamos que se le entrega la siguiente entrada al programa: +1. Crea una función llamada `factorial`, que reciba un número como parámatro y retorne su valor factorial. + +Ejemplo de input: ```bash 8 @@ -17,4 +18,4 @@ Entonces el resultado debería ser: ## 💡 Pistas: -En el caso de una entrada de datos entregada a la cuestión, debería asumirse como una entrada de la consola. +Si no sabes qué es un factorial, revisa la información de este link: https://factorial.mx/numero-funcion-factorial \ No newline at end of file diff --git a/exercises/21-factorial/README.md b/exercises/21-factorial/README.md index 5847c798..82c778c5 100644 --- a/exercises/21-factorial/README.md +++ b/exercises/21-factorial/README.md @@ -2,9 +2,9 @@ ## 📝 Instructions -Write a program which can compute the factorial of a given numbers. -The results should be printed in a comma-separated sequence on a single line. -Suppose the following input is supplied to the program: +1. Create a function named `factorial` which receives a number as parameter and returns the factorial of the given numbers. + +Example input: ```bash 8 @@ -16,6 +16,6 @@ Then, the output should be: 40320 ``` -## 💡Hints: +## 💡 Hints: -In case of input data being supplied to the question, it should be assumed to be a console input. \ No newline at end of file +- If you don't know what a factorial is, you can check it out on this link: https://www.cuemath.com/numbers/factorial/ \ No newline at end of file diff --git a/exercises/21-factorial/app.py b/exercises/21-factorial/app.py index e666e544..fce62c1d 100644 --- a/exercises/21-factorial/app.py +++ b/exercises/21-factorial/app.py @@ -1 +1 @@ -# Your code here \ No newline at end of file +# Your code here diff --git a/exercises/21-factorial/test.py b/exercises/21-factorial/test.py new file mode 100644 index 00000000..1852dcb4 --- /dev/null +++ b/exercises/21-factorial/test.py @@ -0,0 +1,31 @@ +import io, sys, os, re, pytest +import app + +@pytest.mark.it('You should create a function named factorial') +def test_factorial_exists(app): + try: + from app import factorial + assert factorial + except AttributeError: + raise AttributeError("The function 'factorial' should exist on app.py") + +@pytest.mark.it('Testing the function factorial with the number 8, it should return 40320') +def test_factorial_8(app): + try: + assert app.factorial(8) == 40320 + except AttributeError: + raise AttributeError("The function 'factorial' should return the value 40320") + +@pytest.mark.it('Testing the function factorial with the number 3, it should return 6') +def test_factorial_3(app): + try: + assert app.factorial(3) == 6 + except AttributeError: + raise AttributeError("The function 'factorial' should return the value 6") + +@pytest.mark.it('Testing the function factorial with the number 1, it should return 1') +def test_factorial_1(app): + try: + assert app.factorial(1) == 1 + except AttributeError: + raise AttributeError("The function 'factorial' should return the value 1") \ No newline at end of file From 3bbe1172bca36dcb9b6f1c24441e628a5491799a Mon Sep 17 00:00:00 2001 From: Tomas Gonzalez <56565994+tommygonzaleza@users.noreply.github.com> Date: Mon, 17 Jan 2022 18:08:49 -0400 Subject: [PATCH 2/3] Update README.es.md --- exercises/21-factorial/README.es.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/21-factorial/README.es.md b/exercises/21-factorial/README.es.md index b6f72b61..f72157ab 100644 --- a/exercises/21-factorial/README.es.md +++ b/exercises/21-factorial/README.es.md @@ -4,13 +4,13 @@ 1. Crea una función llamada `factorial`, que reciba un número como parámatro y retorne su valor factorial. -Ejemplo de input: +## Ejemplo de entrada: ```bash -8 +factorial(8) ``` -Entonces el resultado debería ser: +## Ejemplo de salida: ```bash 40320 @@ -18,4 +18,4 @@ Entonces el resultado debería ser: ## 💡 Pistas: -Si no sabes qué es un factorial, revisa la información de este link: https://factorial.mx/numero-funcion-factorial \ No newline at end of file ++ Si no sabes qué es un factorial, revisa la información de este link: https://factorial.mx/numero-funcion-factorial From 6c894527d631914d12e109be471216293514a402 Mon Sep 17 00:00:00 2001 From: Tomas Gonzalez <56565994+tommygonzaleza@users.noreply.github.com> Date: Mon, 17 Jan 2022 18:10:03 -0400 Subject: [PATCH 3/3] Update README.md --- exercises/21-factorial/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/21-factorial/README.md b/exercises/21-factorial/README.md index 82c778c5..e5224c90 100644 --- a/exercises/21-factorial/README.md +++ b/exercises/21-factorial/README.md @@ -1,16 +1,16 @@ # `21` Factorial -## 📝 Instructions +## 📝 Instructions: 1. Create a function named `factorial` which receives a number as parameter and returns the factorial of the given numbers. -Example input: +## Example input: ```bash -8 +factorial(8) ``` -Then, the output should be: +## Example output: ```bash 40320 @@ -18,4 +18,4 @@ Then, the output should be: ## 💡 Hints: -- If you don't know what a factorial is, you can check it out on this link: https://www.cuemath.com/numbers/factorial/ \ No newline at end of file ++ If you don't know what a factorial is, you can check it out on this link: https://www.cuemath.com/numbers/factorial/