

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Euler’s criterion in java
According to Euler’s criterion a square root of n under modulo p exists if and only if a number num exists such that num%p is equal to n%p.
Program
import java.util.Scanner; public class EulersCriterion { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter n value :"); int n = sc.nextInt(); System.out.println("Enter p value :"); int p = sc.nextInt(); n = n % p; int flag = 0; for (int num = 2; num < p; num++) { if ((num * num) % p == n) { flag = 1; } } if(flag==1) { System.out.println("root of a number under modulo p exists "); } else { System.out.println("root of a number under modulo p does not exists "); } } }
Output
Enter n value : 2 Enter p value : 7 root of a number under modulo p exists
- Related Questions & Answers
- Euler's Four Square Identity in C++
- What is Euler’s Theorem in Information Security?
- How to get Euler's constant value in JavaScript?
- Euler’s Totient function for all numbers smaller than or equal to n in java
- Euler and Hamiltonian Paths
- Signals and Systems: BIBO Stability Criterion
- Euler Circuit in a Directed Graph
- C++ Program to Implement Euler Theorem
- Euler Method for solving differential equation in C++
- Mean-Variance criterion for defining efficient and inefficient assets
- What is the Kelly Criterion and how does it work?
- Legendre’s Formula in java
- Minimum edges required to add to make Euler Circuit in Python
- Minimum edges required to add to make Euler Circuit in C++
- Format Seconds in s format in Java
Advertisements