Posts

Showing posts from September, 2022

Modulo Multiplication Patterns using Python

Image
This article is inspired from a YouTube video by Mathologer that explains the mathematics behind vortex mathematics and Tesla's 3-6-9 pattern. Please refer the video to understand the logic behind these patterns.  The Python code to generate (at the end) Modulo Multiplication patterns take two inputs, Modulus and Multiplier. Here are some examples with different values of input. Modulus - 500, Multiplier - 2 Multiplier 2 generate the famous cardioid curve. A cardioid is generated by tracing a point on a circle rolling on another circle of the same radius. To read more about cardioid refer to this article .  Modulus - 7417, Multiplier - 240 Some more patterns (Modulus x Multiplier):                          701x260                                               ...

Fibonacci Numbers using Python

Fibonacci sequence is a series of numbers where each number is the sum of two preceding numbers. The sequence is given by: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 and so on We can generate above Fibonacci sequence programmatically with or without recursion.  Fibonacci series without recursion: Below function prints x Fibonacci numbers starting from 0.  def fib (x): a = 0 b = 1 if x < 1 : print ( 'invalid input' ) else : if x == 1 : print (a) else : print (a , end = ' ' ) print (b , end = ' ' ) for i in range ( 2 , x): print (a+b , end = ' ' ) c = a + b a = b b = c fib( 12 ) Output: 0 1 1 2 3 5 8 13 21 34 55 89  Fibonacci series with recursion: def fib (x): if x <= 1 : return x else : return fib(x - 1 ) + fib(x - 2 ) terms = int ( input ( "How many Fibonacci numbers to generate?" )...