I don’t know what’s the issue here: My program is working fine when I use unsigned long int but it gives WA in case of long int or int.

As far as I know range of int on 32 bit machine is 10^9… so my program should work fine using int(since range of n is <= 10^9) but it does not.

my code is

```
#include<stdio.h>
int amt[100000] = {0};
unsigned long int max(unsigned long int n)
{
int val = 0;
if(n <12)
return n;
else if (n<100000)
{
if(amt[n]!=0)
return amt[n];
else
{
val = max(n/2)+max(n/3)+max(n/4);
amt[n] = val;
return val;
}
}
else
{
val = max(n/2)+max(n/3)+max(n/4);
return (n>val?n:val);
}
}
int main()
{
unsigned long int n;
while(scanf("%lu",&n) != EOF)
{
printf("%lu\n", max(n));
}
return 0;
}
```

Kindly Help.