Skip to content

Instantly share code, notes, and snippets.

@lunandd
Created March 14, 2023 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lunandd/6fe270f7215a868783a262d0cdd7cebe to your computer and use it in GitHub Desktop.
Save lunandd/6fe270f7215a868783a262d0cdd7cebe to your computer and use it in GitHub Desktop.
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