You do something complicated involving codes and prime factors, I think, and then somehow the result becomes practically unreplicable and you sell it under the name of bit-, doge- or some other-coin. Whatever the process is, it's CPU intensive and referred to as 'bitcoin mining' as far as I know.
Actually, you generate blocks, and each block must have the latest transactions in it. So by doing the calculations there
is a productive payload - bitcoin transaction processing. So you see, fundamentally there is no reason you can't make a more useful coin, e.g. SETIcoin could be made that does SETI calculations.
As well as transactions, each block also entitles the producer to add their own "i get some coinz" transaction along with the transfers. The cryptography is about load balancing, it makes blocks harder to produce as number of people trying to produce blocks increases, thus ensuring the "block time" stays fairly static. The algorithm is designed to make it CPU intensive to make the block, but be quick for other people to check if a block is valid. Then, whoever is quickest to generate the latest valid block of transactions sends a copy of the block to every PC that maintains a block chain, which is the ledger of who owns how many bitcoins. In fact the "block chain" has every transaction record since the dawn of bitcoin. And millions of machines have a copy of the block chain. They talk to each other and compare a hash value for their blocks too, to ensure that all machines contain the same sequence. This is made easy since there's part of the code that flows from block to block, so one valid block will always have a unique hash signature based on it's contents and the history of every block before it.