It's RSA Algorithm
A great explanation with example here
https://en.wikipedia.org/wiki/RSA_(cryptosystem)
There are phases in RSA.
The prime numbers P and Q is used in Key Generation phase. These numbers are used to generate the Public and Private keys for the sender and receiver.
Computing n,e and d is a part of algorithm. It's a standard process.
In public key cryptography, when A wants to send message to B. A requests B to send it's public key. A then encrypts message using public key of B and sends to B. Now, any intruder cannot decrypt it as it can only be decrypted using B's private key.
Public key is a combination of (n,e) and when A gets this combination from B, it encrypts message using formula
c (cipher) = memod n
The cipher generated can only be decrypted by B's private key. Now, private key is combination of (d,n). Note that value of d is never shared as it's a part of private key for the receiver. Now B decrypts cipher using
m = cdmod n
Hope this helps :)