How to Find the Divisors in C
The challenge
Create a function named divisors
/Divisors
that takes an integer n > 1
and returns an array with all of the integer’s divisors(except for 1 and the number itself), from smallest to largest. If the number is prime return the string ‘(integer) is prime’ (null
in C#) (use Either String a
in Haskell and Result<Vec<u32>, String>
in Rust).
Example:
The solution in C
Option 1:
Option 2:
Option 3:
Test cases to validate our solution
|
|