Encryption/Decryption Modulo function I have an encryption line of code as follows:

a^x mod y = rem // ^ is the power fx


Given x, y, amd rem during decryption, how can we find the value of a? 

I was thinking of using  xth root of rem mod y, but it's not working; probably because of modulo congruence.

Can someone please guide me as to what needs to be done?
You will have to find $d \in \mathbb{Z}_{\varphi(y)}: x * d 
 \equiv 1 (mod\ \varphi(y))$. Then $rem^d=a^{xd}=a^1$ (Euler's theorem) in $\mathbb{Z}_{y}$. To do so you will need to calculate the prime decomposition of $y$ so you can calculate the value of Euler's phi ($\varphi$) in $y$. Then the problem of finding $d$ reduces to the problem of finding inverse (extended Euclidian algorithm on the power and the modulus -- find $a,b$ such that $1=GCD(x,\varphi(y))=ax+b\varphi(y)\equiv ax (mod\ \varphi(y))$). Note that the inverse does not exist if $GCD(x,\varphi(y))\neq1$.

E.g. in RSA the public key ($e$ that corresponds to your $x$) has an inverse ($d$) computed during the key generation and the inverse is then stored in the private key.