Does anybody have any source code for this mathematical question...

it can be in any programming languages (preferably Java, C or C++)....