Created
November 27, 2017 04:38
-
-
Save tedhagos/93fdfe5ed5efbbdda7704c0a75ef0d0e to your computer and use it in GitHub Desktop.
GCF Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html ng-app> | |
| <body ng-controller="ctrl"> | |
| <div id="disp"> | |
| <input type="number" placeholder="type a number" ng-model="fno"/><br/> | |
| <input type="number" placeholder="type a number" ng-model="sno"/><br/> | |
| <button ng-click="calculate()">Calculate</button> | |
| <div id = "out"> | |
| {{ gcf }} | |
| </div> | |
| </div> | |
| <script src="bower_components/angular/angular.js"></script> | |
| <script> | |
| function ctrl($scope) { | |
| $scope.calculate = function() { | |
| let bigno = 0; | |
| let smallno = 0; | |
| let rem = 1; | |
| if($scope.fno > $scope.sno) { | |
| bigno = $scope.fno; smallno = $scope.sno; | |
| } | |
| else { | |
| bigno = $scope.sno; smallno = $scope.fno; | |
| } | |
| while ((rem = bigno % smallno) != 0) { | |
| bigno = smallno; smallno = rem; | |
| } | |
| $scope.gcf = smallno; | |
| } | |
| } | |
| </script> | |
| <style> | |
| body { | |
| font-size: 2em; | |
| } | |
| #disp { | |
| margin-top: 3em; margin-left: 3em; | |
| } | |
| input { | |
| margin-bottom: .5em; | |
| } | |
| </style> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bower angular#1.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment