Calculating n digits of pi using Chudnovsky Algorithm

Chudnovsky Algorithm for calculating π to N digits precision, along with a simple CLI for testing

August 10, 2019

Programming Problem – The City of Archers

Here’s an interesting programming problem that a friend of mine sent me a few days back. Download a working Java solution for this problem here. The City Of Archers Back in human history there used to exist a city known as Genon City .It was always under threat from the enemies but it had the best archers in the world ever known to protect it. To prepare for battle all archers performed similar actions....

January 20, 2011

How to swap two integers in a single line of code?

This question was asked during IBM’s interview in our campus in 2005: How would you swap two integers in one statement without using a temporary variable in C/C++? After thinking about it for some time, this is what I got (this is in Java): class Swap { public static void main( String[] args ) { int a, b; a = 46; b = 47; System.out.println( "a = " + a + ", b = " + b ); a = b | ( 0 & (b = a)); System....

January 20, 2008