Looking for good programming challenges?

Use the search below to find our solutions for selected questions!

All posts in Mathematics

Yield To Maturity calculation using a Python script

When interested in buying bonds a term that often comes up is the definition of Yield To Maturity (YTM): Yield to maturity (YTM) is the total return anticipated on a bond if the bond is held until the end of its lifetime. Yield to maturity is considered a long-term bond . . . Read more

The Knuth shuffle

The Knuth shuffle algorithm is an algorithm for randomly shuffling the elements of an array arr of size given a function that generates a uniformly distributed random number in time. The algorithm produces an unbiased permutation. That is, every permutation is equally likely.

Proof that the algorithm is unbiased . . . Read more

Implement a ceil() function

In this post I will explain a less intuitive approach of implementing a ceil() function in Java, that is faster than known comparison approaches. A few known facts Fact 1 Dividing two integers and in Java will always floor the result:

well almost. Actually Math.floor(a/b) rounds towards negative infinity, . . . Read more

Exponentiation by squaring

This is a rather short post. in which I explain how to we can implement a fast pow function to raise a number to the power of . A rather naive approach would be to do the following:

This is ok, but the algorithm has a running time of . . . Read more