Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions exercises/21-factorial/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

## 📝 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 entrada:

```bash
8
factorial(8)
```

Entonces el resultado debería ser:
## Ejemplo de salida:

```bash
40320
```

## 💡 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
16 changes: 8 additions & 8 deletions exercises/21-factorial/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# `21` Factorial

## 📝 Instructions
## 📝 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
factorial(8)
```

Then, the output should be:
## Example output:

```bash
40320
```

## 💡Hints:
## 💡 Hints:

In case of input data being supplied to the question, it should be assumed to be a console input.
+ If you don't know what a factorial is, you can check it out on this link: https://www.cuemath.com/numbers/factorial/
2 changes: 1 addition & 1 deletion exercises/21-factorial/app.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Your code here
# Your code here
31 changes: 31 additions & 0 deletions exercises/21-factorial/test.py
Original file line number Diff line number Diff line change
@@ -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")