这是我生成数字序列的代码。序列从3开始,并在用户输入的数字的sqaure根处停止。
num = as.numeric(readline(prompt = "Enter a number :"))
mysqrt = as.integer(sqrt(num))
myseq = seq(from = 3,to = mysqrt, by = 2)
我得到的错误是 - >
Error in seq.default(from = 3, to = mysqrt, by = 2) :
wrong sign in 'by' argument
如果我跑 - >
seq(3,as.integer(sqrt(25)), by = 2)
它按预期正常工作。
如果我跑 - >
num = 25
seq(3,as.integer(sqrt(num)), by = 2)
它给出了上述错误。