Mystery Number Program in Java

A number is called mystery number if the sum of two numbers and those two numbers should be the reverse of each other.
Ex: 154

59 95
68 86
77 77

154 is a mystery number.

Ex: 88

17 71
26 62
35 53
44 44

88 is a mystery number.

import java.util.Scanner;
public class MysteryNumber
{
    static int reverse(int n)  
    {
        int reverseNum=0,temp=n,r;
        while (temp > 0)
        {
            r = temp % 10;
            reverseNum = (reverseNum * 10) + r;
            temp = temp / 10;
        }
        return reverseNum;
    }
    
    public static void main(String args[])
    {
        boolean isMysteryNumber=false;
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int num = sc.nextInt(); 
        System.out.println(num);
        for (int n = 1; n <= num / 2; n++)
        {
            int rev_n=reverse(n);
            if (n + rev_n == num)
            {    
                isMysteryNumber=true;
                System.out.println(n + " " + rev_n);
            }
        }
        if (isMysteryNumber)
        {    
            System.out.println(num + " is a mystery number.");
        }
        else
        {
            System.out.println("The given number is not a mystery number.");
        }        
    }
}

Output:

Enter a number: 154
154
59 95
68 86
77 77
154 is a mystery number.
learn java study java