baru003のブログ

baruの雑記兼備忘録

Project Euler

Project Euler 0020

・問題リンクFind the sum of digits in 100!・コメント 概要 n! means n (n 1) ... 3 2 1 For example, 10! = 10 9 ... 3 2 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in …

PE 0001

・問題リンク Add all the natural numbers below one thousand that are multiples of 3 or 5.・コメント 1000未満の自然数のうち3か5の倍数になっている数字の合計を求める問題です。 そのまま実装してacceptできました。・ソース import java.util.…

PE 0006

・問題リンクWhat is the difference between the sum of the squares and the square of the sums?・コメント 100個の自然数の和の二乗と二乗の和の差を求める。・ソース import java.util.*; public class P0006 { public static void main(String[] ar…

PE 0007

・問題リンクFind the 10001st prime.・コメント 自分でこのコーディングは思いつきませんでした(笑) ですが、ソースを読んでなるほどとなりましたね。 ポイントは偶数は2以外は間違いなく素数ではないので判断対象をまず奇数に絞り込み、更に、、素数で…