Computer Science, asked by sdharma45, 5 months ago

Write a program to find the smallest integer value 'b'
for the given value of'a'. If we multiply the digits of
'b', we should get the exact value of 'a'. Result 'b' must
contain more than one digit.
Constraints:
1<=a<=10000
Examples:
Input: 10
Output: 25
Explanation: 2*5 = 10. Hence 25 is the smallest value
for 10.
Input: 56
Output: 78
Explanation: 7*8 = 56
Input: 150
Output: 556
Explanation: 5*5*6 = 150
Input: 13
Output: Not Possible
Instructions:
Input must be a single integer value.
Print "Not Possible" if result not found.​

Answers

Answered by sahuaman843
11

Answer:

#define MAX 50

void findSmallest(int n)

{

   int i, j = 0;  

   int res[MAX];  

   if (n < 10)

   {

       cout << n + 10;

       return;

   }

   for (i = 9; i > 1; i--)

   {

     

       while (n % i == 0)

       {

           n = n / i;

           res[j] = i;

           j++;

       }

   }

 

   if (n > 10)

   {

       cout << "Not possible";

       return;

   }

   for (i = j - 1; i >= 0; i--)

       cout << res[i];

}

Answered by amishamahesh95
2

Answer:

#include<stdio.h>

#include<conio.h>

int main()

{

int x, y, integer;

printf("Enter any two number: ");

scanf("%d%d", &x, &y);

if(x<y)

integer=x;

else

integer=y;

printf("\nSmallest of the two number is: %d", integer);

getch();

}

Similar questions