为什么这段代码中的调试器会显示递归赋值错误?

问题描述 投票:0回答:1
cube := 0;                       
nombre_premiers := 0;
while cube^3 <= 10^4 do
    if isprime(cube) then
        nombres_premiers := nombres_premiers+1 
        end if; 
    cube := cube+1 
    end do;

有人可以向我解释为什么我会出现递归赋值错误吗?

该程序基本上是为等于或小于 10,000 的素数数量递增计数器。

我想这可能与以下事实有关:在每一行的末尾,我按 Shift 键输入,因此代码仅在一行上处理,但我真的不确定。

maple
1个回答
0
投票

您在初始化中使用了不同的拼写,

nombre_premiers := 0

在其他地方你使用这个名字

nombres_premiers

因为

nombres_premiers
只是一个未分配的名称,所以该行,

nombres_premiers := nombres_premiers+1;

会导致这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.