Factoring large numbers is a big problem in CS and Cryptography right now. Some people claim that the NSA can already quickly factor large numbers, others think this to be highly unlikely. If you can discover a way to factor large numbers quickly (or just in polynomial time) then you can either claim one of the large checks established as a prize, sell the information to a government for a large sum of money (being careful they don't kill you in the process), or use the information to either steal large sums of money from bank transactions, or use the information to gain special access to economic information and leverage this knowledge to your advantage. -- Or any other number of fantastic movie plots that deal with breaking cryptographic systems. Your solution may also lead to the answerers to some of the toughest questions in mathematics, making you immortal (in the Shakespearian sense).
Many of the common cryptographic systems, such as RSA, rely in the fact that factoring large numbers is hard. That in order for a computer to do this it must search using some version of well known factoring algorithms.
So the short answer is: You can write a program that establishes a data base of numbers and their factors. So given 21 it looks up the values 3 and 7. You can make this work for as large a value as you would like. But there are an infinite amount of numbers and you can not create an infinite database. Heck you can't even create a very large data base (especially if you are listing the numbers out in text) compared to the 128 bit keys use in browser RSA schemes.
The database idea only becomes useful if there are a finite number (hopefully rather small) of numbers whoes factors you are interested in. The truth is that unless you already know the factors before hand you will have to use on of the known factoring algorithms to establish the data base. Once the database is established you can use it as a lookup table and avoid having to do the work again (meaning the application that uses the factors will run much faster).
As I mentioned before. Factoring large numbers takes a lot of time. So establishing that database may take a while. The algorithms used to factor large numbers are:
- Number field sieve (NFS) - to my knowledge this is the fastest, most efficient known algorithm for number larger than 100 or so digits.
- Quadratic sieve (QS) - This is the fastest algorithm for numbers less than 100 digits or so an second fastest overall.
- Elliptic curve method (ECM) - This is a heavy hitter that is liked because it can be implemented as a non-deterministic method. So kind of like winning the lottery there is a chance of it guessing the right path to quickly find the solution. -- though unlike winning the lottery you are guaranteed to find the solution within a given number of operations (far less then trying all combinations).
There are more methods listed
here.lastly, It is possible to get C/C++ to deal with large numbers without changing them over to scientific notation. The numbers such as +12E+54 are floating point numbers whereas you can use what are commonly called Big Integer (or BigNum) or Arbitrary-precision or Multiple-Precision integers. These require the use of special libraries (though you can code one of your own -- but there are very good libraries already out there) and are not default data types in C/C++ or Java. -- I will note however that it is far more efficient to deal with these numbers in a binary format rather than as text data (so saving the factors in a binary form in your database will be much more efficient than using text -- in both space and time).