Created
March 14, 2023 17:51
-
-
Save lunandd/6fe270f7215a868783a262d0cdd7cebe to your computer and use it in GitHub Desktop.
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
const GROWTH_RATE: f64 = 3.9666; | |
const GENERATIONS: usize = 2000; | |
const STARTING_POPULATION: f64 = 0.975; | |
fn main() { | |
let mut data: Vec<(usize, f64)> = Vec::with_capacity(GENERATIONS); | |
println!("Initial Population: {STARTING_POPULATION}"); | |
data.push((0, STARTING_POPULATION as f64)); | |
for i in 1..=GENERATIONS { | |
let generation_size = data[i -1].1; | |
data.push((i, GROWTH_RATE * generation_size * (1.0 - generation_size))); | |
println!("{:?}", data[i - 1]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment