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 == n
This blog contains coding/programming and interview questions of MNCs like TCS, Wipro, Infosys, Capgemini, Mindtree, Amazon, Google, Facebook, Flipkart, Cisco, HP, Dell, etc. with placement preparation guides.