Skip to content

Commit

Permalink
refactor: nth() and format!() now only called in the case of a mersen…
Browse files Browse the repository at this point in the history
…ne prime
  • Loading branch information
craigmayhew committed May 22, 2024
1 parent efe358f commit 736cd33
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pages/cruncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,12 +619,15 @@ fn html_egyptian(slug: &str, max_len_egyptian: usize) -> Node<Msg> {

fn html_mersenne_prime(str_num: &str) -> Node<Msg> {
let n = mersenne::nth_mersenne_prime(str_num) as usize;
let nth = format!("It is the {} ", nth(n));
let n_th: String;

span![
match n {
0 => "It is not a ",
_ => &nth,
_ => {
n_th = format!("It is the {} ", nth(n));
&n_th
}
},
a![
"mersenne prime",
Expand Down

0 comments on commit 736cd33

Please sign in to comment.