How to calculate the Modulo value of (A^B)modN

 To solve the Modulo value of such expression, I will use java code to find the solution. I will explain the steps required to solve the value using the java code. The steps are as follows.


Step1:- Copy the below code

import java.util.*;

import java.math.BigInteger;

public class Main{

public static void main(String args[])

{

        Scanner sc=new Scanner(System.in);

        BigInteger a,b,n,O;

        System.out.println("Enter value of a");

        a=sc.nextBigInteger();

        System.out.println("Enter value of b");

        b=sc.nextBigInteger();

        System.out.println("Enter value of n");

        n=sc.nextBigInteger();

         O=a.modPow(b,n);

        System.out.println("Answer is");

        System.out.println(O);

      }

}

Step2:- After copying the code, paste the code into the below link. This link will redirect into an Online Java Compiler

                                                        Online Compiler

Step3:- After pasting the code into the Online Java Compiler. Click run and give the inputs. You will get the answer.




Comments

Post a Comment

Popular posts from this blog

How to read a CSV file from Google Drive using Google Colab?

How to calculate WAITING TIME and TURN AROUND TIME in SJF-PRE-EMPTIVE scheduling using C program