Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2010 循环问题。素数列表_Visual Studio 2010_Variables_Loops - Fatal编程技术网

Visual studio 2010 循环问题。素数列表

Visual studio 2010 循环问题。素数列表,visual-studio-2010,variables,loops,Visual Studio 2010,Variables,Loops,我知道一切都大错特错。我想做的是创建一个素数列表,包括给定的数。请尽量简单地解释。我是新来的。非常感谢您的帮助 Option Explicit On Option Strict On 'Author: Murray Spears 'Date: October 5th 2012 'Creating a Program that will ask the user for a number. 'The program will then generate prime numbers up to

我知道一切都大错特错。我想做的是创建一个素数列表,包括给定的数。请尽量简单地解释。我是新来的。非常感谢您的帮助

Option Explicit On
Option Strict On

'Author: Murray Spears
'Date: October 5th 2012

'Creating a Program that will ask the user for a number. 
'The program will then generate prime numbers up to and including the number entered by the user.

Imports System

Module PrimeNumbers

    Sub Main()

        Dim Number As Integer
        Dim One As Integer = 1
        Dim Prime As Boolean


        'Ask the user for their chosen number.
        Console.Writeline("Choose a number:")
        Number = Convert.ToInt32(Console.Readline())
        ' We have to let the program know that we only want numbers that are divisible by one and themselves, up to the entered value.

        Do While Number <= Number
        Loop

        Do While Number / One = Number
        Loop

        Do While Number / Prime = Number
        Loop

        Console.Out.Writeline("Here are the prime numbers:")
        Console.Out.Writeline(Number)

    End Sub

End Module
选项显式打开
选项严格限制在
作者:默里·斯皮尔斯
日期:2012年10月5日
'创建一个程序,要求用户输入一个号码。
'然后程序将生成素数,包括用户输入的数字。
导入系统
模素数
副标题()
整数形式的数字
以整数=1的形式显示尺寸1
作为布尔值的弱素数
'询问用户选择的号码。
Console.Writeline(“选择一个数字:”)
Number=Convert.ToInt32(Console.Readline())
“我们必须让程序知道,我们只想要可以被一和自己整除的数字,直到输入的值为止。
当数字这个


Do虽然我的数字不好,但我把重新格式化的编辑搞砸了。现在修好了。这可能听起来很刺耳(不是故意的),但您应该阅读设置和使用变量和运算符。你有一堆循环,但你什么都不做,所以什么都没有发生。我不确定你在这里挣扎的代码。。。看起来你更像是在努力学习数学。。。我建议你按照海因茨的建议去做。
Do While Number <= Number
Loop