We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Actually there is no need to introduce "reverse += number".It's working well without the use of it.
here is my code:
import java.io.;
import java.util.;
import java.text.;
import java.math.;
import java.util.regex.*;
public class Solution {
public static int reverse(int a)
{
int reverse = 0;
while(a!=0)
{
reverse = reverse * 10;
reverse = reverse + a%10;
a = a/10;
}
return reverse;
}
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner in = new Scanner(System.in);
int i = in.nextInt();
int j = in.nextInt();
int k = in.nextInt();
//int n = i-j+1;
// int s[] = new int[n];
int count = 0;
for(int a = i;a<j+1;a++)
{
int d= a-reverse(a);
if(d%k==0)
count++;
}
System.out.println(count);
}
Beautiful Days at the Movies
You are viewing a single comment's thread. Return to all comments →
Actually there is no need to introduce "reverse += number".It's working well without the use of it. here is my code: import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}