for(x=1,100,print1(eulerphi(n)-1))
0 0 1 1 3 1 5 3 5 3 ... 65 31 43 23 69 2 43 59 45 71 31 95 41 59 39
(我排除了一些整数以使问题简短)我想检查这些数字中是否有一个数字。我该怎么办?
setsearch
通过排序列表执行二进制搜索。它返回匹配项的1个基于1的索引,如果没有发现,则返回0。您的示例在这里:
xs = Set(vector(100, n, eulerphi(n)-1))
> [0, 1, 3, 5, 7, ..., 87, 95]
setsearch(xs, 5)
> 4
setsearch(xs, 20)
> 0