我正在尝试为类编写一个编码问题的程序。我正在考虑做一个while循环,询问素数列表,并以某种方式将它们与字符串进行比较。下面是我的代码。我知道它粗糙。任何一个指向我正确方向的人都会有所帮助。
public static void godel(){
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a list of primes: ");
System.out.println("0 to stop loop ");
int input =0;
int count = 0;
//string 0 = int 1;
//string f = int 3;
//string -\ = int 5;
//string V = int 7;
//string \-/ = int 9;
//string ( = int 11;
//string ) = int 13;
//string /\ = int 15;
//string 3 = int 17;
//string = = int 19;
//string x = int 21;
//string y = int 23
while(true){
input = scanner.nextInt();
if (input != 0)
{
input += count;
}
else{
System.out.println("Here are your list of primes in Godel's Number");
System.out.println(count);
break;
}
} }
我假设什么都没有用?
首先,你需要“public static void main(String [] args)”来弹出任何东西。您要执行的代码(不是任何辅助函数或数学,只是想要打印)应该在该语句中
public static void main(String[] args)
{
//code you want to execute here
}
我不确定godel是什么东西,你还需要在代码的顶部导入这样的扫描仪库:
import java.util.Scanner;
我不知道你是否需要听到这些,但这看起来像一个跑步者,因为你打印了很多东西而且你有扫描仪。我很困惑为什么没有args语句或库,但我想你可能只是没有包含它。
我对数论一无所知,所以我无法帮助解决这个问题。