Question: Problem Statement Given a string of integers, write a program to generate an output string as follows i ) From the input integers, filter the
Problem Statement
Given a string of integers, write a program to generate an output string as follows
i From the input integers, filter the integers that are perfect squares. Ex: dots
ii For each perfect square obtained from step find its factorial. If the factorial of the number is trailing by zeros, three digits present before the trailing zeros should be appended to output string. If not trailing by zeros append last three digits to output string. If there is a preceding zero, it is ignored.
i If the number is then it does not have any trailing zeros and there is only one digit in it so append to output.
ii If the number is then it has one trailing zero and before the trailing zero there are only two digits present so append to output.
iii. If the number is then it has one trailing zero, before trailing zero there are five digits present, so consider three digits before trailing zero that is and append to output.
iv If the number is then it has two trailing zeros, before trailing zeros there are seven digits present, so consider three digits before trailing zero that is as is preceded here, is ignored and is appended to output.
iiilf there are no positive perfect squares in the input string print
Example:
Input String:
Perfect squares from input are:
Factorial of the perfect squares are:
Factorial is not trailing by zero. Hence, will be considered as it is in Output
Factorial is trailing by zero. Hence, last digits before zero will be considered
Factorial is trailing by zero. Hence, last digits before zero will be considered
Hence, Output will be:
Input Format: Input string contains all the numbers separated by comma.
Output Format: All the values in output string should be printed in the form of single string, where values should be separated by comma. And in case, there are no positive perfect squares then should be printed.
Input Format: Input string contains all the numbers separated by comma.
Output Format: All the values in output string should be printed in the form of single string, where values should be separated by comma. And in case, there are no positive perfect squares then should be printed.
tableSample Input,Sample Output,ExplanationNAtableThere are no perfectsquares present in theinput so will beprintedtableConsidered only positivenumbers in the input
Languages: Python
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
