Search⌘ K

Challenge 1: Find The Factorial

Explore loop constructs in Rust by solving a factorial problem. Learn to implement for and while loops to calculate the factorial of a number, including handling negative inputs. This exercise strengthens your understanding of iteration and control flow in Rust.

Problem Statement

The task is to print the factorial of a number n.

The factorial of a number n is the product of all numbers from 1 to n.

factorial(n)=n(n1)(n2)...1 ...