Created
January 25, 2014 18:51
-
-
Save LESTADru/8621429 to your computer and use it in GitHub Desktop.
Получение X в степени n. Проверяем что бы n
быд больше 0.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<script> | |
function getPow(x, n){ | |
var result = x; | |
for(var i=1;i<n;i++){ | |
result *= x; | |
} | |
return result; | |
} | |
// код ;) | |
var x= +prompt('x?', ''); | |
var n= +prompt('n?', ''); | |
if (n <= 1){ | |
alert('Степень ' + n + ' не поддерживается, введите целую степень, большую 1'); | |
}else { | |
alert(getPow(x, n)); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment