59 lines
1.3 KiB
HTML
59 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
<script>
|
|
// var str = "233333333333333333333"
|
|
// var strnew=""
|
|
// var i = 0
|
|
// var typer=setInterval(()=>{
|
|
// if(str[i]){
|
|
// document.write(str[i])
|
|
// i=i+1
|
|
// }
|
|
|
|
// },1000)
|
|
// if(i==str.length){
|
|
// clearInterval(typer)
|
|
// }
|
|
// document.write(str[i])
|
|
|
|
|
|
// 10
|
|
//
|
|
function mofa(n){
|
|
let str=""
|
|
if(typeof n=="number"){
|
|
if(n>0&&n<=10){
|
|
while(n>0){
|
|
if(n%2){
|
|
str="1"+str
|
|
n=(n-1)/2
|
|
}else{
|
|
str="2"+str
|
|
n=(n-2)/2
|
|
}
|
|
}
|
|
}else{
|
|
console.log("n必须小于10")
|
|
}
|
|
}else{
|
|
console.log("请输入数字")
|
|
}
|
|
|
|
return str
|
|
}
|
|
let mfb=mofa(10)
|
|
console.log(mfb)
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
</body>
|
|
|
|
</html> |