Unit 2 Task 20: Factorial orderings

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Unit 2 Task 20 - Factorial orderings

← Unit 2 tasks · Solution


The number of ways to arrange N different books in a row is N factorial (written N!): 1 × 2 × … × N.

Ask for N (integer, assume N ≥ 1 and keep N small, e.g. at most 12). Use a loop to compute N! and print it.

Skills: for, accumulation with multiplication.

Example: N = 4 → 24.