Created
May 7, 2015 07:14
-
-
Save lenka21/db6eb191cc6fd7a704ea to your computer and use it in GitHub Desktop.
silnia
This file contains 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 lang="pl"> | |
<meta charset="UTF-8"> | |
<title>silnia</title> | |
<script src="main.js"></script> | |
</head> | |
<body> | |
<h1>Podaj liczbe</h1> | |
<input id="n"> | |
<button onclick="licz()">Licz silnie</button> | |
<h2 id="view"></h2> | |
</body> | |
</html> |
This file contains 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
function silnia(){ | |
var n = document.getElementById("n").value; | |
var result = 1; | |
if (n < 0) { | |
result = "n musi byc wieksze lub rowne 0"; | |
} else { | |
for (var i = 1; i <= n; i++){ | |
result = result*i; | |
} | |
} | |
document.getElementById("view").innerHTML = result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment