Modulus of nth Fibonacci Number

As part of an assignment I was asked to find an optimized algorithm to find the m modulus of nth Fibonacci number.
Sounds pretty easy, untill you see the size of the inputs, n has 30 digits in it.

At this stage, basic methods or brute force methods will take eons to finish this. And I had to go back to Maths to find the solution.
The algorithm came from here
Using A matrix equation for calculating super huge fibonacci numbers.

What we are trying to achieve is

F(n) % n # Where F(n) is the nth Fibonacci Number.

Below is the python code for the same.

Simple touch controls in Unity

I started trying out Unity since Unity 5, which comes with new UI Component.
The UI Layer makes things very easy. It wraps all UI elements inside a Canvas.
Its easy to scale this and it comes with some predefined scaling and positioning rules.

For creating a custom touch pad, we add a blank image object to the Canvas. We can
position this from UI with respect to the camera. We can attache a sprite to this
to make it easier for players to identiy the input area and its purpose.

The SimpleTouchPad Class exposes a method GetDirection which can be checked from the game objet controller
to see if there are any movements triggered.


Welcome to my blog. is where I used to talk about my experiments and
discoveries in programming. Unfortunately the data from the old website is lost. All that remains
is the name. I thought I will start again. And this is my attempt at talking code again.

Unity, Look at Target C#

Learning Unity is so much fun. The Unity Engine has almost everything that you wish there was.
Below is a script which lets an attached game controller to rotate its transform so that it looks at the targets transform position