Opening Hours :7AM to 9PM
class PetersonNumber { public boolean isPeterson(int n) { int sum = 0; int product = 1; while (n > 0) { int digit = n % 10; sum += digit; product *= digit; n /= 10; } return sum == product; } } public class Main { public static void main(String[] args) { PetersonNumber pn=new PetersonNumber(); int n = 371; System.out.println(n + " is" + (pn.isPeterson(n) ? "" : " not") + " a Peterson number."); } }This program defines a method isPeterson that takes an integer n as input and returns true if n is a Peterson number, and false otherwise.