How should i approach this problem

question toh samaj aa gya lekin kese start kru yeh samaj nhi aa rha

@anujsharmabadboy no datatype in c++ is capable of holding such a large value so you can store the digits of the number in an array. for eg 5! is 120 so you can make an array like int arr = {1, 2, 0}

You can start with {1} and perform multiplication operations on this array. for eg if array is {6} and you multiply it with 4
then 6*4 = 24 you can store 24 / 10 = 2 in the current place and the carry becomes 24 % 10 = 4 and store it in the next place.

logic toh samaj aa gya lekin kese krna h yeh logic nhi aa rha

@anujsharmabadboy you can start writing the code and i’ll be happy to help wherever you are stuck. One tip is that in the array, you can store the number backwards for easy processing. Like to store 120 you can store {0,1,2} instead of 120 which will make multiplying and updating the array easier.

kuch nhi ban rha …

@anujsharmabadboy you cant expect others to write the code for you if you are stuck…give it some time. All you have to do is initialise an array with{1,0,0…} for starting out

@Ishitagambhir
whenever we write #define MAX 500

  1. what is the advantage there, we can also write MAX=500 in the function ??
  2. is there any difference between them in working or anything ??
  3. even if array is there arr[MAX] does it make any difference from these two ???

@Ishitagambhir
whenever we write #define MAX 500

  1. what is the advantage there, we can also write MAX=500 in the function ??
  2. is there any difference between them in working or anything ??
  3. even if array is there arr[MAX] does it make any difference from these two ???

@anujsharmabadboy the only difference is that #define is a macro so it is processed before the code is compiled. You can read more about preprocessing directives. Otherwise there is no difference in their working.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.