• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






dark_lake

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

2013年4月27日

ProjectEuler 8
摘要: 找出如下1000个整数中5个连续的数最大的乘积/** * Find the greatest product of five consecutive digits in the 1000-digit * number. * * 73167176531330624919225119674426574742355349194934 * 96983520312774506326239578318016984801869478851843 * 85861560789112949495459501737958331952853208805511 * 1254069874715852386... 阅读全文
posted @ 2013-04-27 15:57 dark_lake 阅读(132) 评论(0) 推荐(0)
 
ProjectEuler 7
摘要: 求第10001个素数/** * 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? */代码:private static int nthPrime(int N) { if (N == 1) return 2; int k = 1; while (--N > 0) { k = k + 2; while (!isPrime(k)) ... 阅读全文
posted @ 2013-04-27 15:48 dark_lake 阅读(143) 评论(0) 推荐(0)
 
ProjectEuler 6
摘要: 求n个数和的平和与n的平方和的差/** * The sum of the squares of the first ten natural numbers is, * * 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural * numbers is, * * (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of * the squares of the first ten natural nu... 阅读全文
posted @ 2013-04-27 15:47 dark_lake 阅读(116) 评论(0) 推荐(0)
 
ProjectEuler 5
摘要: 求能够被1-20中任意一个数整除的最小正整数/** * 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? */代码:private static long smallMul(int N) { long r =... 阅读全文
posted @ 2013-04-27 15:38 dark_lake 阅读(126) 评论(0) 推荐(0)
 
ProjectEuler 4
摘要: 求最大的回文数,同时回文数是2个三位数的乘积/** * A palindromic number reads the same both ways. The largest palindrome * made from the product of two 2-digit numbers is 9009 = 91 99. * * Find the largest palindrome made from the product of two 3-digit numbers. */代码:private static int largePalin(int n) { if (n < 1... 阅读全文
posted @ 2013-04-27 15:31 dark_lake 阅读(111) 评论(0) 推荐(0)
 
ProjectEuler 3
摘要: 求600851475143最大的素数因子/** * The prime factors of 13195 are 5, 7, 13 and 29. * * What is the largest prime factor of the number 600851475143 ? */代码:private static long maxPrime(long N) { int max = 1; if (N % 2 == 0) max = 2; for (int i = 1; i <= Math.sqrt(N); i = i + 2) if (N % i == 0) { ... 阅读全文
posted @ 2013-04-27 15:23 dark_lake 阅读(141) 评论(0) 推荐(0)
 
ProjectEuler 2
摘要: 求斐波那契数列中不超过400万的偶数之和/** * 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 values do not * ex... 阅读全文
posted @ 2013-04-27 15:14 dark_lake 阅读(157) 评论(0) 推荐(0)
 
ProjectEuler 1
摘要: 最近被腾讯打击到了,下决心开始写技术博客。第一件事开始做朋友推荐的Project Euler,网址http://projecteuler.net。练练代码,也练练思想,本周做了8题,均用java实现,希望有看到的人帮忙提提意见Problem 1求1000以下所有3或者5倍数的数之和/** * 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 * ... 阅读全文
posted @ 2013-04-27 15:06 dark_lake 阅读(138) 评论(0) 推荐(0)