ã¨ãã転è·ãµã¤ãã«ã®ã£ã¦ããåé¡ãã¨ãã¦ã¿ã
ã¨ãã転è·ãµã¤ãã«ã®ã£ã¦ããåé¡ãã¨ãã¦ã¿ã¾ãã
247ãªã©ã®æ´æ°ã渡ãã¨2+4+7ããã¦ããã¨ããåé¡ã§ã
public static int plus(int num) { int result = 0; for (int i = num ; i ! = 0 ; i = i / 10) { result += i % 10; } return result; }
ãªã«ã調ã¹ãªãã§ï¼ï¼å以å
ã«è§£ãã£ã¨ãããã®
ã ãããï¼ï¼åãããã§ãã
ã§ãã³ã¼ããããããå¦ãããã£ã¨éè¦ãªã®ã§ã
ãã®ãã¨æ¡æ°ã®åºãæ¹ã調ã¹ã¦ãªãã¡ã¯ã¿ãªã³ã°ãããªã©
追è¨
foræã®æ¡ä»¶ãã¡ãã£ã¨æ¹å