把1-100 间的所有合数找出来并用素数的乘积来表示·C#编写

来源:百度知道 编辑:UC知道 时间:2024/06/06 12:59:23
用C#编写。

在线等
主要是

把1-100 间的所有合数找出来并用素数的乘积来表示

这个乘积表示 不会````

除了2(这个是质偶数)和质数,其他都是合数

我想想再 帮你写吧

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Temp
{
class Program
{
static void Main(string[] args)
{
//输出素数
Console.Write("2 ");
for (int i = 3; i < 101; i+=2)
if (IsPrime(i))
Console.Write(i+" ");
Console.WriteLine();

//输出合数分解(但是最后有一个*号没有处理完··你先想办法我要上课了!!)
for (int i = 3; i <= 100; i++)
{
int k = i;
if (IsPrime(i))
continue;
Console.Write(k + "=");
for (int j = 2; j <i; j++)
{
if (k % j == 0)
{