Created
August 7, 2013 22:10
-
-
Save danielef/6179274 to your computer and use it in GitHub Desktop.
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
input { | |
padding: 5px; | |
width: 90%; | |
} | |
div { | |
padding: 5px; | |
width: 100%; | |
} | |
button { | |
width: 90%; | |
} |
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> | |
<head> | |
<title>Problema 3</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> | |
<script src="http://documentcloud.github.io/underscore/underscore-min.js"></script> | |
</head> | |
<body> | |
<div> | |
<input type="text" id="n" value="123"/> | |
</div> | |
<div> | |
<button id="e">evaluar entero</button> | |
</div> | |
<div> | |
<input type="text" id="a"/> | |
</div> | |
</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
$(document).ready(function() { | |
$("#e").click(function() { | |
$("#a").val(sum($("#n").val())); | |
}); | |
}); | |
function sum(n) { | |
return (n === 0) ? 0: n%10 + Math.floor(sum(n/10)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment