esercizi js
This commit is contained in:
31
js_3.html
Normal file
31
js_3.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head lang="en">
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
|
||||
function f (n) {
|
||||
var base = n-1;
|
||||
if (n > 1)
|
||||
return n * base * f( n - 2);
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
value = prompt("Inserire numero tra 1 e 15");
|
||||
|
||||
if ( value && !isNaN(value) && value>=1 && value<=15 )
|
||||
document.writeln(f(value));
|
||||
else
|
||||
alert("Error");
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user