【Project Euler】7 第七题



//By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

//What is the 10 001st prime number?

static void Main(string[] args)
        {
            int count = 0;
            for (int i = 3; i < 1000000; i++)
            {
                int index = -1;
                for (int j = 2; j < i; j++)
                {
                    if (i % j != 0 && i != j)
                    {

                    }
                    else
                    {
                        index += 1;
                    }
                }
                if (index == -1)
                {
                    //Console.WriteLine(i);
                    count += 1;
                }
                if(count==10000)
                {
                    Console.WriteLine(i);
                }
            }
        }

时间: 2024-07-29 19:05:43

【Project Euler】7 第七题的相关文章

【Project Euler】1 第一题

 //If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. //Find the sum of all the multiples of 3 or 5 below 1000.  static void Main()         {             int sum=0;     

【Project Euler】2 第二题

 //Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: //1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... //By considering the terms in the Fibonacci sequence whose valu

【Project Euler】9 第九题

 A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. static void Main(s

使用CoffeeScript来解决Project Euler中的编程问题

本 系列 文章将探讨 CoffeeScript,这是构建于 http://www.aliyun.com/zixun/aggregation/33906.html">JavaScript 基础之上的一种全新编程语言,它提供了非常干净的语法.CoffeeScript 可编译为高效的 JavaScript.除了在 Web 浏览器中运行 JavaScript 之外,您还可以将它与服务器应用程序的 Node.js 等技术一起使用.在 第 1 部分 中,学习了如何设置 CoffeeScript 编译器

用python解决project euler中的题目

寒假期间学习了python,现在基本上就能上手使用它来解决project euler里面的题目了,用python真的是没得说的,一个字"赞".在C++中需要用一大堆代码实现的算法,在python中,只需要那么短短几行.而且还有惊艳的运行速度.借用<可爱的python>里面的一句话:"人生苦短,我用python". [project euler 055] 求经过一系列规则不能得到回文数的数的个数.题目在此: If we take 47, reverse a

经典算法题每日演练——第七题 KMP算法

原文:经典算法题每日演练--第七题 KMP算法       在大学的时候,应该在数据结构里面都看过kmp算法吧,不知道有多少老师对该算法是一笔带过的,至少我们以前是的, 确实kmp算法还是有点饶人的,如果说红黑树是变态级的,那么kmp算法比红黑树还要变态,很抱歉,每次打kmp的时候,输 入法总是提示"看毛片"三个字,嘿嘿,就叫"看毛片算法"吧. 一:BF算法      如果让你写字符串的模式匹配,你可能会很快的写出朴素的bf算法,至少问题是解决了,我想大家很清楚的知

Project euler 18题解答

 By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 37 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom of the triangle below

【Project Euler】5 第五题

 //2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. //What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?         static void Main(string[] args

【Project Euler】3 第三题

 //The prime factors of 13195 are 5, 7, 13 and 29.         //What is the largest prime factor of the number 600851475143 ?         static void Main(string[] args)         {             //int[] number = new int[100];             long[] number = new