Sum of the digits of an integer in lua
问题 I saw a question like this relating to Java and C, but I am using LUA. The answers might have applied to me, but I wasn't understanding them. Could someone please tell me how I would get the sum of the individual digits of an Integer. For Example. a = 275 aSum = 2+7+5 If you could explain how I would achieve this in LUA and why the code does what it does, that would be greatly appreciated. 回答1: Really a simple function. Using gmatch will get you where you need to go. function sumdigits(str)