A nonce is calculated by using a cryptographic function, known as an algorithm, which is typically built into the mining software provided by a cryptocurrency.