擅长:python、mysql、java
<p>当然,您可以在这里使用递归:</p>
<pre><code>def small_enough(a, limit):
if a:
return a[0] <= limit and small_enough(a[1:], limit)
else:
return True
</code></pre>
<p>甚至是</p>
^{pr2}$
<p>但是你的解决方案确实比这个更具可读性。此外,递归<a href="https://stackoverflow.com/questions/931762/can-every-recursion-be-converted-into-iteration">doesn't actually avoid looping</a>,只是看起来不同而已。在</p>