早教吧 育儿知识 作业答案 考试题库 百科 知识分享

N是一个大于1的整数,试给出一个操作步骤,对N是否为质数作出判定

题目详情
N是一个大于1的整数,试给出一个操作步骤,对N是否为质数作出判定
▼优质解答
答案和解析
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Class1
{
//质数:只能被1和自己整除的数字
static void Main()
{
string s = Console.ReadLine();
int x = int.Parse(s);
//假设是质数
bool ok = true;
int count = 0;
//for (int i = 2; i < x; i++)
//如果不是质数,乘积一定是一个数比平方根小,一个数比平方根大
//for (int i = 2; i