Core Beginner

01  Functions

Implement small functions. The final expression in a block, written without a semicolon, is the value the function returns.

Step 1 / 2

Implement square so it returns n * n.

Hints
  • fn name(arg: Type) -> RetType { ... }.
  • No return needed -- leave the last line without a semicolon.
01_functions.rs
Reset to starterCompiled in a sandbox; hidden checks must pass.
Reveal solution
fn square(n: i32) -> i32 {
    n * n
}