Frankly, I have no idea. The equation you have been given, that is easy to implement - you almost have it yourself, but I suspect that X is not supposed to be a boolean but rather that
mod n != 1
is a constraint rather than a part of the equation.
But other than that, we just don't have much information: which of the variables
y
,
p
,
q
, and
n
are intended to be random? Which should be BigInteger types? If it's any of them, then you will need to use the BigInteger version of Math.Pow, and that only comes in one version:
BigInteger.Pow(BigInteger, Int32) Method (System.Numerics) | Microsoft Docs[
^]
What you need to do is probably re-read your task carefully, and work out exactly what it is asking you to do - you have paraphrased it here and we can't work out from that what your teacher has asked you to do.
If you are having problems getting started at all, then this may help:
How to Write Code to Solve a Problem, A Beginner's Guide[
^]