Skip to content

Instantly share code, notes, and snippets.

@tedhagos
Created November 27, 2017 04:38
Show Gist options
  • Select an option

  • Save tedhagos/93fdfe5ed5efbbdda7704c0a75ef0d0e to your computer and use it in GitHub Desktop.

Select an option

Save tedhagos/93fdfe5ed5efbbdda7704c0a75ef0d0e to your computer and use it in GitHub Desktop.
GCF Solution
<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>
bower angular#1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment