mirror of
https://github.com/ArthurDanjou/exercism-rust.git
synced 2026-01-30 19:57:48 +01:00
Initial commit
This commit is contained in:
19
short-fibonacci/src/lib.rs
Normal file
19
short-fibonacci/src/lib.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
/// Create an empty vector
|
||||
pub fn create_empty() -> Vec<u8> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
/// Create a buffer of `count` zeroes.
|
||||
///
|
||||
/// Applications often use buffers when serializing data to send over the network.
|
||||
pub fn create_buffer(count: usize) -> Vec<u8> {
|
||||
vec![0;count]
|
||||
}
|
||||
|
||||
/// Create a vector containing the first five elements of the Fibonacci sequence.
|
||||
///
|
||||
/// Fibonacci's sequence is the list of numbers where the next number is a sum of the previous two.
|
||||
/// Its first five elements are `1, 1, 2, 3, 5`.
|
||||
pub fn fibonacci() -> Vec<u8> {
|
||||
vec![1, 1, 2, 3, 5]
|
||||
}
|
||||
Reference in New Issue
Block a user