My worst mathematical program in perl

I have a Mathe-crap-matical friend. Who keeps digging into graves of dead formulas and equations and all possible Math related stuffs.
Since I started understanding Mathematics (that it’s not my cup of tea), I tried to stay away from it.

Now, that enthu creature mailed me his requirement. He says he “eat mathematics”, I prefer to stay away from such guys. But as a good friend I read his mails.

His requirement was to create a program. His requirements are:

N is a natural number falling in range [1 - 999999]
X is a number given by user with range [6000 - 20000]

You have to write a program such that you find a number N whose square root or cube root is such that the first digit of X comes in the Xth decimal place and second digit of X comes in the (X+1)th decimal place and so on…

e.g. user enters 12…
then the number N would be such that CubeRoot(N) or SqRoot(N) = dddd.ddddddddddd12

You may write program in any language.

[ad#ad-2-250x250img]

Check screen shot to understand what it does [note the name]:

maths program

maths program

Alright, I understood the dooms day is closing in… Did you notice the decimal places correction he was asking? 6000!! Damn…

Any ways, I chose perl and accomplished the task. I’m not sure how and why he need this thing but still I hope it rested his soul. :)

This post is for people like me who have such math-e-manic friends.
You may download my script my_mathematics_pgm.pl.

You might also like::

  1. Perl Script for Analyze – Optimize – Repair Mysql Databases
  2. Audit-Checking login history-to know WHO DID THAT on Redhat Linux