Skip to content
created by Aha00aAha00a at 2016-12-23
last modified by Aha00aAha00a at 2016-12-23
revision: 2

ProjectEuler Problem34

http://projecteuler.net/index.php?section=problems&id=34

Digit factorials

145는 1! + 4! + 5! = 1 + 24 + 120 = 145인 귀여운 수다.

자신의 숫자의 factorial의 합이 자신과 같은 모든 수의 합을 구하라.

Note: 1! = 1 와 2! = 2 는 합이 아니라서 포함되지 않는다.

1. Solution

40730

ProjectEulerProblem20에서 factorial을 가져왔다.

new {
  def factorial(x: Int): Int = {
    @tailrec
    def f(x: Int, acc: Int): Int = if (x == 0) acc else f(x - 1, x * acc)
    f(x, 1)
  }
  val factorials = (0 to 9).map(factorial(_))
  val ans = (3 to 100000).filter(i => i == i.toString.map(Character.getNumericValue).map(factorials).sum).sum
}.ans

278ms 걸린다. --2016-12-23

2. See Also

2.2. Similar Pages

Similar pages by cosine similarity. Words after page name are term frequency.

2.3. Adjacent Pages

Control
≤ 32
all
1.0x
1.0x
80
-120
ON
Metrics
Nodes(visible/total)0/0
Links(visible/total)0/0
Avg degree0.00
Depth coverage0
Queue(fetch/graph)0 / 0
Zoom(scale)1.00x
Ctrl/⌘ + Scroll: Zoom
Root 1-hop 2-hop+