Yes well i actually need the space for memorizing a lot of numbers.
See my code :

Code:
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int *tabela;//or maybe a static array

int max(int a,int b)
{
    if(a<=b)return b;
  return a;
}
 

int f(int n)
{
    if(n==1)return 1;
    if(n==2)return 2;
   
    if(tabela[n]==0){
                    tabela[n]=max(n,f(n/2)+f(n/3)+f(n/4));
                     }
    return tabela[n];
}

int main()
{
    int i,n;
    
    tabela= (int *)calloc(500000000 , sizeof (int));
    
 tabela[1]=1;
tabela[2]=2;
tabela[3]=3;
 while(scanf("%d",&n)!=0)printf("%d\n",f(n));
 free(tabela);

return 0;
}
and a really don't know any other way to do this