C / C++ / C#

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

Programming Challenge 14 - Multiply Big Numbers

Now Completed

By David Bolton, About.com

This programming Challenge ran until the end of July 2008 and was about multiplying pairs of numbers as quickly as possible

All you have to do is read a text file containing 100 pairs of numbers, then multiply the two numbers in each pair together and output them into another file. You have to do this as quickly as possible in C, C++ or C# and time how long it takes to multiply all 100 pairs of numbers.

So what's the catch? Well the numbers are each 100 digits long and you can't use any 3rd party library to do the multiplication. You must code it yourself. The answers should be about 200 digits long.

The numbers file Download Numbers File consists of 200 lines of input numbers, with each line having exactly one 100 digit number. So read them all in and multiply the first two together then the next two and so on.

Output

This should be a text file called answers.txt in the same folder as your executable. It should have 100 lines each with a 200 digit number.

Please include the total time it took, including the time to load the numbers data file and output the answers file. This is the code that you can use for timing.

Results

Congratulations to Makis whose multi threading multiply was very fast indeed. The top ten have a link to the download of their source files as submitted. Thank you to everyone who entered.

Note: I made a mistake with Stole's timing and left out Dennis Muhlestein's entry completely but both are now fixed.

  1. Makis Tsintsikloglou (Greece,33) - C# Score = Time(secs) = 0.0021329
  2. Michael Chock - C++ Score = Time(secs) = 0.00697955
  3. Vivek Malhotra - C++ Score = Time(secs) = 0.010851
  4. Stephen Franceschell - C# Score = Time(secs) = 0.0113713
  5. Pedro Graca(Portugal) - C Score = Time(secs) = 0.014235
  6. Jure Potočnik(Slovenia,28) - C# Score = Time(secs) = 0.0271458
  7. klins(India,20) - C++ Score = Time(secs) = 0.0280809
  8. John Boyd/Christopher Lovejoy(USA) - C# Score = Time(secs) = 0.0288331
  9. Dennis Muhlestein(USA,31) - C++ Score = Time(secs) = 0.0424296
  10. Arturo Alatriste Trujillo(Mexico,32) - C Score = Time(secs) = 0.05455
  11. St0le(India) - C++ Score = Time(secs) = 0.120755
  12. Yanjiang QIAN(China) - C Score = Time(secs) = 0.198056
  13. Rafel Sytek(Poland) - C++ Score = Time(secs) = 0.53216
  14. St0le(India) - C++ Score = Time(secs) = 0.120755
  15. Vikas M. Ranjane(India,20) - C Score = Time(secs) = Stack Corrupted

More Programming Challenges

Explore C / C++ / C#

About.com Special Features

C / C++ / C#

  1. Home
  2. Computing & Technology
  3. C / C++ / C#
  4. Projects
  5. Programming Challenges
  6. Programming Challenge 14 - Multiply Big Numbers

©2009 About.com, a part of The New York Times Company.

All rights reserved.