Is it possible to create a program that will update itself?
For an example of a use for such a program, here is a c++ function that will return Fibonacci number n:
It ends up being very slow as it is recursive, so I was wondering if it is possible for the program to check for a case x, and if it isn't there, add it, so the computer can speed up. So if you did this function with 15, it would add:
if it isn't already there.
If it is possible, how would it be done?
For an example of a use for such a program, here is a c++ function that will return Fibonacci number n:
Code:
unsigned long Fibonacci(unsigned long x)
{
unsigned long y;
switch (x)
{
case 0:
y = 0;
break;
case 1:
y = 1;
break;
case 2:
y = 1;
break;
default:
y = Fibonacci(x-1) + Fibonacci(x-2);
break;
}
return y;
}
Code:
case 15:
y = 610;
break;
If it is possible, how would it be done?