39

4

There is a rather curious number which shows up sometimes in math problems or riddles. The pseudofactorial(N) is the least (i.e. lowest) common multiple of the numbers 1 through N; in other words, it's the lowest number which has all numbers from 1 through N as factors.

For instance pseudofactorial(7) = 3 * 4 * 5 * 7, which is the same as 7! except that 2 and 6 have been removed because they are contained in other terms.

Write a program to calculate pseudofactorial(N) and as always, shortest code wins.

Here is a short list for your use. More test cases can be found in the OEIS under A003418.

Factorial:

- 1
- 2
- 6
- 24
- 120
- 720
- 5040

Pseudofactorial:

- 1
- 2
- 6
- 12
- 60
- 60
- 420

6I'm not sure I understand why

`2`

and`6`

were removed from the list of multiples. Can please you clarify the rules? – Maltysen – 2016-06-09T20:23:37.0802@Mattysen, psuedofactorial(N) is the smallest number which has the numbers 1 through N as factors (The least common multiple of those numbers). That is the technical definition, but the way I wrote it was somewhat suggestive that it is similar to a factorial. – Tony Ruth – 2016-06-09T20:26:39.930

@TonyRuth ohh i see now, thanks. – Maltysen – 2016-06-09T20:27:21.630

2https://oeis.org/A003418 – Neil – 2016-06-10T00:19:10.873

4Welcome to Programming Puzzles & Code Golf! This is a nice first challenge! – Alex A. – 2016-06-10T00:40:52.120

1Your first challenge got to the top of HNQ. Nice! – Daniel M. – 2016-06-10T00:56:11.300

Thanks, I've never really asked many questions on stack exchange, tried more to answer, but this came up in a puzzle. What is HNQ? – Tony Ruth – 2016-06-10T00:59:26.707

Hot Network Questions. – Neil – 2016-06-10T08:34:41.980