Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
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.