Naive recursion can repeat the same calculation millions of times.
A recursive function that calls itself on overlapping sub-problems recomputes the same answers again and again. The textbook example is Fibonacci; real code does it with tree walks, pricing rules and path searches.
A study found that storing results of repeated calls can cut energy by up to 74%. GreenCode's energy rules for AI coding agents cover this too.
GreenCode helps tackle this by refactoring flagged code one element at a time: it writes any missing tests and documentation first, and returns every change as a pull request for a person to approve. More on this.
Share this