Skip to main content
added 455 characters in body
Source Link
Martin Ender
  • 198.2k
  • 67
  • 455
  • 999

CJam, 13 bytes

q~{\_p1$/)*}* 

Input as a CJam-style list. Output is linefeed separated.

[Test it here.][1]

Explanation

q~ e# Read and evaluate input. { e# Fold this block over the list (i.e. "foreach except first")... \ e# Swap with previous value. _p e# Duplicate and print previous value. 1$ e# Copy current value. / e# Integer division. )* e# Increment and multiply current value by the result. }* 

The final value is left on the stack and printed automatically at the end.

[1]: http://cjam.aditsu.net/#code=q~%7B%5C_p1%24%2F)%7D&input=%5B15%208%2012%2047%2022%2015%204%2066%2072%2015%203%204%5D

CJam, 13 bytes

q~{\_p1$/)*}* 

Input as a CJam-style list. Output is linefeed separated.

[Test it here.][1]

[1]: http://cjam.aditsu.net/#code=q~%7B%5C_p1%24%2F)%7D&input=%5B15%208%2012%2047%2022%2015%204%2066%2072%2015%203%204%5D

CJam, 13 bytes

q~{\_p1$/)*}* 

Input as a CJam-style list. Output is linefeed separated.

[Test it here.][1]

Explanation

q~ e# Read and evaluate input. { e# Fold this block over the list (i.e. "foreach except first")... \ e# Swap with previous value. _p e# Duplicate and print previous value. 1$ e# Copy current value. / e# Integer division. )* e# Increment and multiply current value by the result. }* 

The final value is left on the stack and printed automatically at the end.

[1]: http://cjam.aditsu.net/#code=q~%7B%5C_p1%24%2F)%7D&input=%5B15%208%2012%2047%2022%2015%204%2066%2072%2015%203%204%5D

Source Link
Martin Ender
  • 198.2k
  • 67
  • 455
  • 999

CJam, 13 bytes

q~{\_p1$/)*}* 

Input as a CJam-style list. Output is linefeed separated.

[Test it here.][1]

[1]: http://cjam.aditsu.net/#code=q~%7B%5C_p1%24%2F)%7D&input=%5B15%208%2012%2047%2022%2015%204%2066%2072%2015%203%204%5D