If the lambda needs a specific name to work (because you're calling it recursively), then you'll have to count the declaration and definition of that name, I'm afraid. So it'll have to be something like
Func<int,int>f=n=>n<2?1:f(n-1)+f(n-2);
Not entirely sure if that requires some additional space somewhere. I'm also not sure whether the compiler would accept var
there as the type, but in any case, you'll have to count all the code that's required to make the answer work and declare the necessary names.
Note that not all languages require named functions for recursion. For example, in Mathematica, you can refer to the nearest surrounding unnamed function with #0
, which means that
If[#<2,1,#0[#-1]+#0[#-2]]&
would be a valid submission, because here a name is not required to make the function work. (That said, I think a named function would actually be shorter, but that's beside the point.)