Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Reverse Prime
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int[] arr={13,63,37,47,69}; for(int i=0;i<arr.length;i++){ int rev=0,temp=0; if(isprime(arr[i])){ temp=arr[i]; while(temp>0){ rev=(rev*10)+temp%10; temp=temp/10; } if(isprime(rev)){ System.out.println(arr[i]+" is reverse prime."); } } } } public static boolean isprime(int n){ boolean res=true; for(int i=2;i<=n/2;i++){ if(n%i==0){ res=false; break; } } return res; } }
run
|
edit
|
history
|
help
0
output1
Hi
Java - Swap two numbers without using temp var
exp6
call function
JAVA # Cümleye Boşluk Bırakma 2
m-primes
binary
Kochergina_2
Palindrome String Checking