From 0413e8fd4e6b4d6168bd0979c1bed5dab5e27ca2 Mon Sep 17 00:00:00 2001 From: Unbewohnte Date: Sun, 13 Feb 2022 16:26:37 +0300 Subject: [PATCH] Fixed mandelbrot funcion comment --- src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index fd89bcf..988ec91 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,12 +28,13 @@ use num::Complex; use std::sync::{Arc, Mutex}; /// z(n) = z(n-1)^2 + c -/// Returns amount of iterations to decide that z will escape to infinity +/// Returns amount of iterations that were necessary to decide that z escapes to infinity. +/// Returns None if z doesn`t escape to infinity even after specified number of iterations fn mandelbrot(c: num::Complex, iterations: u32) -> Option { let mut z: Complex = num::Complex::new(0.0, 0.0); - for i in 0..iterations { + for n in 0..iterations { if z.norm_sqr() > 4.0 { - return Some(i); + return Some(n); } z = z * z + c; }