题目是这样的:
/* QUESTION
Write a short program that that prints all prime numbers to a log file between
2 and 1000. Your program can assume 2 and 3 are prime numbers from the outset.*/
把2~1000里所有的质数,展示在log文件里,可以设定2,3是已知质数
下面是我写的命令,作为一个小白,看不出来哪儿错了,但是一直在报错
clear all
set more off
cap log close
global Primes 2 3
forvalue i=4/1000{
local isPrime = 1
foreach n of Prime{
local reminder = mod(`i',`n')
if reminder == 0 {
local isPrime = 0
}
}
if isPrime == 1 {
global Primes $Primes `i'
}
}
display "Prime numbers are $Primes"