A number P is said to be the seed of another number Q if multiplying P with its digits equates to Q.
Ex:- 123 is seed of 738 as 123 * 1 * 2 * 3 = 738
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | public class Seed{ public static void main(String[] args){ int num1 = 123, num2 = 738; num1 = Math.min(num1,num2); num2 = Math.max(num1,num2); System.out.println(checkSeed(num1, num2)); } public static boolean checkSeed(int num1, int num2){ int seed = num1; while(num1>0){ seed = seed * (num1%10); num1 = num1 / 10; } if(seed==num2) return true; else return false; } } |
Python
def checkSeed(num1,num2): seed = num1 while num1 > 0: seed = seed * (num1 % 10) num1 = num1//10 if seed==num2: return True return False num1, num2 = 123, 738 print(checkSeed(min(num1,num2),max(num1,num2))) |