IMO 1960 Problem 01 _ex_ forked:1favorite:0lines:41license : MIT License modified : 2009-07-07 22:27:12 Embed Tweet <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="480" height="360" backgroundColor="#FFFFFF" xmlns="*"> <mx:ApplicationControlBar dock="true" width="100%"> <mx:Label id="lblProblem" x="10" y="10" width="380" height="80"> <mx:text> <![CDATA[ IMO 1960 Problem 01 Determine all three-digit numbers N having the property that N is divisible by 11, and N/11 is equal to the sum of the squares of the digits of N. ]]> </mx:text> </mx:Label> <mx:Button id="btnSolve" x="395" y="55" click="solve();" label="Solve!" /> </mx:ApplicationControlBar> <mx:Script> <![CDATA[ public function solve():void { txtResult.text = ""; var count:int = 1; var k:int = 10; while (k * 11 < 1000) { // Calculate sum of the squares of the digits var sumSquares:int = 0; var n:int = k * 11; while (n > 0) { var digit:int = n % 10; sumSquares += digit * digit; n /= 10; } // Check if (sumSquares == k) { txtResult.text += count + ") " + (k * 11) + "\n"; ++count; } ++k; } } ]]> </mx:Script> <mx:TextArea id="txtResult" x="5" y="15" width="470" height="250" /> </mx:Application> Code Fullscreen Preview Fullscreen math problem sort new page view favorite forked pv469 IMO 1962 Problem 01 _ex_ forked:0 favorite:0lines:43 (diff:29) tag: math problems