c# - Recursion and return a function -


i have following code in javascript , write same in c#. don't know how recursion , returning function together.

function findsequence(goal) {   function find(start, history) {     if (start == goal)       return history;     else if (start > goal)       return null;     else       return find(start + 5, "(" + history + " + 5)") ||              find(start * 3, "(" + history + " * 3)");   }   return find(1, "1"); } 

i thought work isn't.

public static func<int, string, string> findsequence(int goal) {     var find = new func<int, string, string>(start, history => {         if (start == goal)             return history;         else if (start > goal)             return null;         else             return (find(start + 5, "(" + history + " + 5)") ||                      find(start * 3, "(" + history + " * 3)"));         });          return find;     } 


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -