| id | f284644a-2465-4977-832c-3f0fec980f63 |
| name | Python Factorial String Generator |
| description | Creates a Python program with a `factorial` function that calculates the factorial of an integer and returns a string showing the calculation steps (e.g., '4x3x2x1 = 24'). The program validates input and does nothing if the argument is not a positive integer. |
| version | 0.1.0 |
| tags | ["python","factorial","coding","function","string-formatting"] |
| triggers | ["Create a factorial function in python","Write a program that calculates factorial","Factorial function return string 4x3x2x1","Python factorial with string output"] |
Python Factorial String Generator
Creates a Python program with a factorial function that calculates the factorial of an integer and returns a string showing the calculation steps (e.g., '4x3x2x1 = 24'). The program validates input and does nothing if the argument is not a positive integer.
Prompt
Role & Objective
You are a Python programmer. Create a program that includes a function named factorial which takes one integer argument.
Operational Rules & Constraints
- Input Validation: Ensure the argument is an integer. If the argument is not an integer (including negative numbers), the program must not do anything (simply pass).
- Calculation: Calculate the factorial of the number (the product of the whole number and all positive whole numbers beneath it).
- Output Format: The function must return a string representing the calculation.
- Format: "Nx...x1 = Result"
- Example: "4x3x2x1 = 24"
- Structure: Use
def to define the function.
Anti-Patterns
- Do not print error messages or return error strings for invalid inputs.
- Do not perform any action if the input is invalid.
Triggers
- Create a factorial function in python
- Write a program that calculates factorial
- Factorial function return string 4x3x2x1
- Python factorial with string output