我的代码有什么问题吗?当我运行该程序时,没有任何内容被打印。我想打印能被 1 到 20 的所有数字整除的最小数字。
found = False
i = 20
while found==False:
c = 0 # c checks if the number is the one im looking for
for x in range(1,21):
if i%x==0:
c = c + 1
if c==20: # if c = 20 then its the number im looking for
print i
found = True
i = i + 1
Run Code Online (Sandbox Code Playgroud) 我的代码出了什么问题?当正确答案显然为6,8时,它打印2,2
public static void main(String[] args) {
int a = 1;
int b = 1;
int answer = 0;
int j = 4;
while (j == 4) {
for (a = 1; a <= 10; a++) {
for (b = 1; b <= 10; b++) {
answer = a * a + b * b;
if (answer == 100) {
j = 10;
}
}
}
}
System.out.println(a + " " + b);
}
Run Code Online (Sandbox Code Playgroud)