Posts

Showing posts with the label inlab 6

INLAB 6

IN-LAB 6 Q.Given ‘n’ integers, write an algorithm and the subsequent Python code to print all numbers that are sum-equivalent to the first number. Two numbers  ‘m’ and ‘n’ are said to be sum-equivalent if  ‘m’ and ‘n’ have the same number of digits and the sum of the digits in ‘m’ and ‘n’ are equal.  12381 is sum-equivalent to 10545. Here both the numbers are five digit numbers. Sum of the digits in 12381 is 1+2+3+8+1=15. Similarly the sum of the digits in 10545 is 15. Write a function to check whether two numbers are sum-equivalent or not. If none of the numbers are sum-equivalent then print ‘No sum-equivalent’. Input Format First line contains the number of elements, n Next ‘n’ line contains the numbers Output Format Print first number in the first line Next few lines contain the numbers that are sum-equivalent to first number. If the none of the numbers are sum-equivalent , then Print “No sum-equivalent” Input: the number of elements ...