Created
June 12, 2021 20:12
-
-
Save ttsugriy/cede61a2dcca263f4b4c7a6b61474112 to your computer and use it in GitHub Desktop.
Sum of N, Rust version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[no_mangle] | |
pub fn sum_of_n_unsigned(n: usize) -> usize { | |
let mut total = 0; | |
for i in 1..=n { | |
total += i; | |
} | |
total | |
} | |
#[no_mangle] | |
pub fn sum_of_n_signed(n: i32) -> i32 { | |
let mut total = 0; | |
for i in 1..=n { | |
total += i; | |
} | |
total | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment