In Python

Godbolt does Python! (And lots of other languages…) import cmath # Set how far to zoom into the set, you can tweak this value scale = 25 # Calculate if each point in an x-y plane "escapes" the shape for y in range(-12, 12): for x in range(-55, 45): # Create a complex number based on current coordinates # Note the fudge factor of 2 because characters are taller than high c = complex(x / scale, y / scale * 2) # Initialise the calculation z = 0 # Check if calculation remains bounded (stays on the page) for _ in range(20): # THE IMPORTANT BIT! [Read More]

What does it all mean?

Means Mean: the average value of a data set Median: the middle of a data set, the number that splits a data set in two; requires sorting; median of an even number of elements is the mean of the middle two elements Mode: value in a data set that occurs most often; if a data set has unique numbers there is no mode; if there are equal numbers of some elements there are multiple modes Random variables Discrete: finite numbers of values Continuous: infinite number of values Probability density functions P(|Y - 2| < . [Read More]

The Fibonacci Sequence

In different languages

Bash #!/bin/bash function fibonacci { local n=$1 [[ $n == 0 ]] && echo $n && return [[ $n == 1 ]] && echo $n && return local x=$(fibonacci $((n - 1))) local y=$(fibonacci $((n - 2))) echo $((x + y)) } echo -e sh\\t$(fibonacci 14) C #include <stdio.h> unsigned int fibonacci(const unsigned int); int main() { printf("c\t%d\n", fibonacci(14)); return 0l; } unsigned int fibonacci(const unsigned int n) { return ( n < 2 ? [Read More]