## Count the Fractions.

This is the first in a series of posts about sequences of fractions, circles, trees of fractions, binary search trees and ways of representing rational numbers as paths through these trees . The idea is to enjoy a bit of recreational mathematics and to use Haskell to express some of the notions in its own succinct way. One Lot Of Fractions First we’ll look at all unique and simplified fractions between 0 and 1 with a denominator no larger than a given value. For example, with a maximum denominator of 3, 4 and then 5 we have     For Read More

## Continued Fractions, Pell’s Equation and Scary Numbers.

This is Pell’s equation: where n is a positive integer that isn’t a perfect square. Only integer solutions for x and y are sought and if n is not a perfect square then there are infinitely many integer solutions. It can be shown that the convergents of the continued fraction (CF) for the square root of n contains a solution known as the Fundamental Solution (FS). In practice this fundamental solution is the first convergent that satisfies the equation under consideration. Once this solution is known then all other solutions can be calculated from a simple recurrence relationship. i.e. If Read More

## Parsers to Fractions to Square Roots!

The earlier post Fractions to Phi to Fibonacci! showed a simple structure for Continued Fractions (CF) and used a CF representation of the Golden Ratio to derive the terms of the Fibonacci Sequence. It also alluded to a particular notation to express a CF and here we will describe that notation, create a parser for it and calculate the square roots of some integers from their specific CFs and finally derive a general CF that can be used to find the square root of any integer.   CF List Notation Essentially the CF is written as a list of ints Read More

## Kaprekar’s Constant.

Just recently I came across ‘Kaprekar’s Constant‘ and maybe Mr Kaprekar had too much spare time… but still, it is quite interesting. The idea is to take a 4 digit number where the digits are not all the same then make the largest and smallest numbers possible with these digits, subtract the smaller from the larger then rinse and repeat with the result of the subtraction. e.g start with 4123 4321 – 1234 = 3087 8730 – 0378 = 8352 8532 – 2358 = 6174 7641 – 1467 = 6174 … repeats… and in fact all 4 digits ‘converge’ to Read More