{"action":"created","comment":{"url":"https://api.github.com/repos/dtep/Euler1/pulls/comments/42144581","id":42144581,"diff_hunk":"@@ -32,90 +188,152 @@ public static int EulerTask1(int numOfElements)\n             return sum;\n         }\n \n-        //Generane Fibonacci numbers from 3 to upperLimit and count the sum of even elements\n-        public static int GenerateFibonacci(int upperLimit)\n-    {\n-        if (upperLimit < 10) return -1;\n-        int fibonacci_first = 1;\n-        int fibonacci_second = 2;\n-        int fibonacci_temp = 0;\n-        int fibonacci_sum = 0;\n-        bool isEven = false;\n-        if (fibonacci_first % 2 == 0) fibonacci_sum = fibonacci_sum + fibonacci_first;\n-\n-            do {\n-                if (fibonacci_second % 2 == 0)\n+        /**\n+         *  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:\n+         *    1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...\n+         *   By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.\n+         */\n+        public static int EulerTask2(int limit)\n+        {\n+            int fibonacci_sum = 0;\n+            ListClass fibonacci = new ListClass();\n+            foreach (int current in fibonacci.GetFibonacci(limit))\n+            {\n+                if (current % 2 == 0)\n                 {\n-                    fibonacci_sum = fibonacci_sum + fibonacci_second;\n-                    isEven = true;\n+                    fibonacci_sum += current;\n                 }\n-                fibonacci_temp = fibonacci_first;\n-                fibonacci_first = fibonacci_second;\n-                fibonacci_second = fibonacci_second + fibonacci_temp;\n-\n-                Console.WriteLine(\"Number {0} is {1}\" , fibonacci_first,isEven);\n-                isEven = false;\n             }\n-            while (fibonacci_second<upperLimit);\n             return fibonacci_sum;\n-            \n-    }\n-\n-        public static List<long> primeList;\n-        \n-      //Genegate global array of prime numbers from 2 to Limit\n-        public static void GeneratePrimeList(long Limit)\n-    {\n-        bool isPrime = false;\n-            primeList = new List<long> ();\n-            primeList.Add(2);\n-            primeList.Add(3);\n-            \n+        }\n \n-        for (long i = 4; i < Limit;i++ )\n+        /** \n+         *  The prime factors of 13195 are 5, 7, 13 and 29.\n+         *  What is the largest prime factor of the number 600851475143 ?\n+         */\n+        public static long EulerTask3(long value)\n         {\n-            foreach (long number in primeList )\n+\n+            long limit = (long)Math.Sqrt(value);\n+            Console.WriteLine(\"Limit is {0}\", limit);\n+            List<long> primeList = new List<long>();\n+\n+            if (value < 3) throw new ArgumentOutOfRangeException(\"Number is too low\"); ;\n+\n+            for (long i = 3; i <= limit; i += 2)\n             {\n-                if (i % number == 0)\n+                if ((value % i) == 0 && i.IsPrime())\n+                    primeList.Add(i);\n+\n+            }\n+            return primeList.Max();\n+        }\n+\n+        /*\n+         *  A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.\n+         *  Find the largest palindrome made from the product of two 3-digit numbers.\n+         */\n+        public static int EulerTask4()\n+        {\n+            int numFirst = 999;\n+            int numSecond = 999;\n+            List<int> palindromeList = new List<int>();\n+\n+            for (int i = numFirst; i > 100; i--)\n+                for (int j = numSecond; j > 100; j--)\n                 {\n-                    isPrime = false;\n-                    break;\n+                    if (EulerUtils.IsPalindrome(i * j)) palindromeList.Add(i * j);","path":"Euler1/EulerProblemSolver.cs","position":277,"original_position":277,"commit_id":"3d0fb51aab2ac63fe716244324f6afd7aff8140d","original_commit_id":"3d0fb51aab2ac63fe716244324f6afd7aff8140d","user":{"login":"SergeyTeplyakov","id":726448,"avatar_url":"https://avatars.githubusercontent.com/u/726448?v=3","gravatar_id":"","url":"https://api.github.com/users/SergeyTeplyakov","html_url":"https://github.com/SergeyTeplyakov","followers_url":"https://api.github.com/users/SergeyTeplyakov/followers","following_url":"https://api.github.com/users/SergeyTeplyakov/following{/other_user}","gists_url":"https://api.github.com/users/SergeyTeplyakov/gists{/gist_id}","starred_url":"https://api.github.com/users/SergeyTeplyakov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SergeyTeplyakov/subscriptions","organizations_url":"https://api.github.com/users/SergeyTeplyakov/orgs","repos_url":"https://api.github.com/users/SergeyTeplyakov/repos","events_url":"https://api.github.com/users/SergeyTeplyakov/events{/privacy}","received_events_url":"https://api.github.com/users/SergeyTeplyakov/received_events","type":"User","site_admin":false},"body":"Вот еще один кандидат на метод расширения в класс NumberExtensions. Будет тогда выглядить так:\r\n\r\n```c#\r\nvar candidate = i * j;\r\nif (candidate.IsPalindrome) {...}\r\n```\r\n\r\nКстати, есть смысл, просто, чтобы потренироваться, попробовать избавиться от `palindromeList`. По идее, для вычисления максимального значения нет никакого смысла сохранять все полиндромы...\r\n","created_at":"2015-10-15T16:08:52Z","updated_at":"2015-10-15T16:08:52Z","html_url":"https://github.com/dtep/Euler1/pull/5#discussion_r42144581","pull_request_url":"https://api.github.com/repos/dtep/Euler1/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/dtep/Euler1/pulls/comments/42144581"},"html":{"href":"https://github.com/dtep/Euler1/pull/5#discussion_r42144581"},"pull_request":{"href":"https://api.github.com/repos/dtep/Euler1/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/dtep/Euler1/pulls/5","id":47651308,"html_url":"https://github.com/dtep/Euler1/pull/5","diff_url":"https://github.com/dtep/Euler1/pull/5.diff","patch_url":"https://github.com/dtep/Euler1/pull/5.patch","issue_url":"https://api.github.com/repos/dtep/Euler1/issues/5","number":5,"state":"open","locked":false,"title":"Euler task 7","user":{"login":"dtep","id":12472348,"avatar_url":"https://avatars.githubusercontent.com/u/12472348?v=3","gravatar_id":"","url":"https://api.github.com/users/dtep","html_url":"https://github.com/dtep","followers_url":"https://api.github.com/users/dtep/followers","following_url":"https://api.github.com/users/dtep/following{/other_user}","gists_url":"https://api.github.com/users/dtep/gists{/gist_id}","starred_url":"https://api.github.com/users/dtep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtep/subscriptions","organizations_url":"https://api.github.com/users/dtep/orgs","repos_url":"https://api.github.com/users/dtep/repos","events_url":"https://api.github.com/users/dtep/events{/privacy}","received_events_url":"https://api.github.com/users/dtep/received_events","type":"User","site_admin":false},"body":null,"created_at":"2015-10-14T12:16:28Z","updated_at":"2015-10-15T16:08:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"71bf5b8d90873ca65738bee33c119322d35e8658","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dtep/Euler1/pulls/5/commits","review_comments_url":"https://api.github.com/repos/dtep/Euler1/pulls/5/comments","review_comment_url":"https://api.github.com/repos/dtep/Euler1/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dtep/Euler1/issues/5/comments","statuses_url":"https://api.github.com/repos/dtep/Euler1/statuses/3d0fb51aab2ac63fe716244324f6afd7aff8140d","head":{"label":"dtep:Euler-task-4","ref":"Euler-task-4","sha":"3d0fb51aab2ac63fe716244324f6afd7aff8140d","user":{"login":"dtep","id":12472348,"avatar_url":"https://avatars.githubusercontent.com/u/12472348?v=3","gravatar_id":"","url":"https://api.github.com/users/dtep","html_url":"https://github.com/dtep","followers_url":"https://api.github.com/users/dtep/followers","following_url":"https://api.github.com/users/dtep/following{/other_user}","gists_url":"https://api.github.com/users/dtep/gists{/gist_id}","starred_url":"https://api.github.com/users/dtep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtep/subscriptions","organizations_url":"https://api.github.com/users/dtep/orgs","repos_url":"https://api.github.com/users/dtep/repos","events_url":"https://api.github.com/users/dtep/events{/privacy}","received_events_url":"https://api.github.com/users/dtep/received_events","type":"User","site_admin":false},"repo":{"id":43974214,"name":"Euler1","full_name":"dtep/Euler1","owner":{"login":"dtep","id":12472348,"avatar_url":"https://avatars.githubusercontent.com/u/12472348?v=3","gravatar_id":"","url":"https://api.github.com/users/dtep","html_url":"https://github.com/dtep","followers_url":"https://api.github.com/users/dtep/followers","following_url":"https://api.github.com/users/dtep/following{/other_user}","gists_url":"https://api.github.com/users/dtep/gists{/gist_id}","starred_url":"https://api.github.com/users/dtep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtep/subscriptions","organizations_url":"https://api.github.com/users/dtep/orgs","repos_url":"https://api.github.com/users/dtep/repos","events_url":"https://api.github.com/users/dtep/events{/privacy}","received_events_url":"https://api.github.com/users/dtep/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dtep/Euler1","description":"","fork":false,"url":"https://api.github.com/repos/dtep/Euler1","forks_url":"https://api.github.com/repos/dtep/Euler1/forks","keys_url":"https://api.github.com/repos/dtep/Euler1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dtep/Euler1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dtep/Euler1/teams","hooks_url":"https://api.github.com/repos/dtep/Euler1/hooks","issue_events_url":"https://api.github.com/repos/dtep/Euler1/issues/events{/number}","events_url":"https://api.github.com/repos/dtep/Euler1/events","assignees_url":"https://api.github.com/repos/dtep/Euler1/assignees{/user}","branches_url":"https://api.github.com/repos/dtep/Euler1/branches{/branch}","tags_url":"https://api.github.com/repos/dtep/Euler1/tags","blobs_url":"https://api.github.com/repos/dtep/Euler1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dtep/Euler1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dtep/Euler1/git/refs{/sha}","trees_url":"https://api.github.com/repos/dtep/Euler1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dtep/Euler1/statuses/{sha}","languages_url":"https://api.github.com/repos/dtep/Euler1/languages","stargazers_url":"https://api.github.com/repos/dtep/Euler1/stargazers","contributors_url":"https://api.github.com/repos/dtep/Euler1/contributors","subscribers_url":"https://api.github.com/repos/dtep/Euler1/subscribers","subscription_url":"https://api.github.com/repos/dtep/Euler1/subscription","commits_url":"https://api.github.com/repos/dtep/Euler1/commits{/sha}","git_commits_url":"https://api.github.com/repos/dtep/Euler1/git/commits{/sha}","comments_url":"https://api.github.com/repos/dtep/Euler1/comments{/number}","issue_comment_url":"https://api.github.com/repos/dtep/Euler1/issues/comments{/number}","contents_url":"https://api.github.com/repos/dtep/Euler1/contents/{+path}","compare_url":"https://api.github.com/repos/dtep/Euler1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dtep/Euler1/merges","archive_url":"https://api.github.com/repos/dtep/Euler1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dtep/Euler1/downloads","issues_url":"https://api.github.com/repos/dtep/Euler1/issues{/number}","pulls_url":"https://api.github.com/repos/dtep/Euler1/pulls{/number}","milestones_url":"https://api.github.com/repos/dtep/Euler1/milestones{/number}","notifications_url":"https://api.github.com/repos/dtep/Euler1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dtep/Euler1/labels{/name}","releases_url":"https://api.github.com/repos/dtep/Euler1/releases{/id}","created_at":"2015-10-09T18:53:31Z","updated_at":"2015-10-09T18:53:37Z","pushed_at":"2015-10-14T19:52:59Z","git_url":"git://github.com/dtep/Euler1.git","ssh_url":"git@github.com:dtep/Euler1.git","clone_url":"https://github.com/dtep/Euler1.git","svn_url":"https://github.com/dtep/Euler1","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"dtep:master","ref":"master","sha":"3dc56d03c1bad97beebecf09230015b29da8f434","user":{"login":"dtep","id":12472348,"avatar_url":"https://avatars.githubusercontent.com/u/12472348?v=3","gravatar_id":"","url":"https://api.github.com/users/dtep","html_url":"https://github.com/dtep","followers_url":"https://api.github.com/users/dtep/followers","following_url":"https://api.github.com/users/dtep/following{/other_user}","gists_url":"https://api.github.com/users/dtep/gists{/gist_id}","starred_url":"https://api.github.com/users/dtep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtep/subscriptions","organizations_url":"https://api.github.com/users/dtep/orgs","repos_url":"https://api.github.com/users/dtep/repos","events_url":"https://api.github.com/users/dtep/events{/privacy}","received_events_url":"https://api.github.com/users/dtep/received_events","type":"User","site_admin":false},"repo":{"id":43974214,"name":"Euler1","full_name":"dtep/Euler1","owner":{"login":"dtep","id":12472348,"avatar_url":"https://avatars.githubusercontent.com/u/12472348?v=3","gravatar_id":"","url":"https://api.github.com/users/dtep","html_url":"https://github.com/dtep","followers_url":"https://api.github.com/users/dtep/followers","following_url":"https://api.github.com/users/dtep/following{/other_user}","gists_url":"https://api.github.com/users/dtep/gists{/gist_id}","starred_url":"https://api.github.com/users/dtep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtep/subscriptions","organizations_url":"https://api.github.com/users/dtep/orgs","repos_url":"https://api.github.com/users/dtep/repos","events_url":"https://api.github.com/users/dtep/events{/privacy}","received_events_url":"https://api.github.com/users/dtep/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dtep/Euler1","description":"","fork":false,"url":"https://api.github.com/repos/dtep/Euler1","forks_url":"https://api.github.com/repos/dtep/Euler1/forks","keys_url":"https://api.github.com/repos/dtep/Euler1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dtep/Euler1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dtep/Euler1/teams","hooks_url":"https://api.github.com/repos/dtep/Euler1/hooks","issue_events_url":"https://api.github.com/repos/dtep/Euler1/issues/events{/number}","events_url":"https://api.github.com/repos/dtep/Euler1/events","assignees_url":"https://api.github.com/repos/dtep/Euler1/assignees{/user}","branches_url":"https://api.github.com/repos/dtep/Euler1/branches{/branch}","tags_url":"https://api.github.com/repos/dtep/Euler1/tags","blobs_url":"https://api.github.com/repos/dtep/Euler1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dtep/Euler1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dtep/Euler1/git/refs{/sha}","trees_url":"https://api.github.com/repos/dtep/Euler1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dtep/Euler1/statuses/{sha}","languages_url":"https://api.github.com/repos/dtep/Euler1/languages","stargazers_url":"https://api.github.com/repos/dtep/Euler1/stargazers","contributors_url":"https://api.github.com/repos/dtep/Euler1/contributors","subscribers_url":"https://api.github.com/repos/dtep/Euler1/subscribers","subscription_url":"https://api.github.com/repos/dtep/Euler1/subscription","commits_url":"https://api.github.com/repos/dtep/Euler1/commits{/sha}","git_commits_url":"https://api.github.com/repos/dtep/Euler1/git/commits{/sha}","comments_url":"https://api.github.com/repos/dtep/Euler1/comments{/number}","issue_comment_url":"https://api.github.com/repos/dtep/Euler1/issues/comments{/number}","contents_url":"https://api.github.com/repos/dtep/Euler1/contents/{+path}","compare_url":"https://api.github.com/repos/dtep/Euler1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dtep/Euler1/merges","archive_url":"https://api.github.com/repos/dtep/Euler1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dtep/Euler1/downloads","issues_url":"https://api.github.com/repos/dtep/Euler1/issues{/number}","pulls_url":"https://api.github.com/repos/dtep/Euler1/pulls{/number}","milestones_url":"https://api.github.com/repos/dtep/Euler1/milestones{/number}","notifications_url":"https://api.github.com/repos/dtep/Euler1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dtep/Euler1/labels{/name}","releases_url":"https://api.github.com/repos/dtep/Euler1/releases{/id}","created_at":"2015-10-09T18:53:31Z","updated_at":"2015-10-09T18:53:37Z","pushed_at":"2015-10-14T19:52:59Z","git_url":"git://github.com/dtep/Euler1.git","ssh_url":"git@github.com:dtep/Euler1.git","clone_url":"https://github.com/dtep/Euler1.git","svn_url":"https://github.com/dtep/Euler1","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dtep/Euler1/pulls/5"},"html":{"href":"https://github.com/dtep/Euler1/pull/5"},"issue":{"href":"https://api.github.com/repos/dtep/Euler1/issues/5"},"comments":{"href":"https://api.github.com/repos/dtep/Euler1/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/dtep/Euler1/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/dtep/Euler1/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dtep/Euler1/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/dtep/Euler1/statuses/3d0fb51aab2ac63fe716244324f6afd7aff8140d"}}}}