C # find the prime numbers 1-100, daffodils number 100-1000, 1-100 square root sum of squares of all

// your encouragement is my greatest motivation than we can leave comments in the next long period of time I will update you have wanted to learn every day from beginner to advanced can also leave a message oh

// now it is what I do on the 28th day of the teacher C #, I hope we work together and refuel

using System;

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

the FOR namespace
{
class Program
{
static void the Main (String [] args)
{
// a determined prime number between 1 to 100. What is a prime number. Primes: starting from 2 except that the whole can not be any count and itself is called a prime number such as 2,3,5,7

int count = 0; // calculator
for (int I = 2; I <= 100; I ++)
{
BOOL = Zhi to true;
for (int J = 2; J <I; J ++)
{
IF (J == I% 0)
{
Zhi = to false;
BREAK;
}
}
IF (== Zhi to true)
{
COUNT ++;
Console.WriteLine ( "prime number within 1-100 has 0} {", I);
}
}
Console.WriteLine ( "l- prime number less than a total of {100 0} ", count);

// 2 obtained within a few daffodils daffodils 100-1000 What is the number? Narcissistic number: "153 =. 1 *. 1 *. 1 +. 5 *. 5 *. 5 +. 3 *. 3 *. 3"
for (int K = 100; K <1000; K ++)
{
int GE = K% 10;
int Shi = ( (K-GE)% 100) / 10;
int Bai = (- K-(GE Shi * + 10)) / 100;
int * SXH = Bai Bai Bai * * + Shi Shi Shi * * GE * + GE GE;
IF (K == SXH)
{
Console.WriteLine ( "Narcissus number 100-1000 has less than 0} {", K);
}

}

And obtaining the square root @ 1-100
for (int. 1 = H; H <100; H ++)
{
int * PF = H H;
Double Math.Sqrt PFG = (H);
Console.WriteLine ( "{0} {1} is a square, the square root} 2 { ", H, PF, PFG);
}
}
}
}

Guess you like

Origin www.cnblogs.com/LanPeng/p/10969169.html