| Bytes | Lang | Time | Link |
|---|---|---|---|
| 034 | TIBASIC TI83 Plus | 250515T130552Z | madeforl |
| 038 | Juby | 250514T194536Z | Jordan |
| 016 | Perl 5 n | 240203T065716Z | Xcali |
| 003 | Vyxal | 240203T060215Z | emanresu |
| 003 | Uiua SBCS | 240203T004501Z | chunes |
| 008 | K ngn/k | 220507T100611Z | oeuf |
| 022 | Factor | 220507T064041Z | chunes |
| 047 | Desmos | 220507T061504Z | Aiden Ch |
| 005 | MathGolf | 181007T003319Z | Jo King |
| 005 | J | 181007T080512Z | Galen Iv |
| 013 | dc | 181012T071133Z | eush77 |
| 029 | PowerShell | 181011T225816Z | Veskah |
| 003 | MATL | 181006T164828Z | Giuseppe |
| 009 | K oK | 181010T144252Z | Thaufeki |
| 040 | Python 2 | 181010T142025Z | Steven H |
| 006 | Pyth | 181007T075932Z | Steven H |
| 003 | 05AB1E | 181008T065636Z | Kevin Cr |
| 002 | Husk | 181008T035034Z | Leo |
| 039 | Python 3 | 181007T144912Z | Quintec |
| 067 | Common Lisp | 181007T083223Z | Renzo |
| 003 | Japt | 181006T192032Z | Shaggy |
| 069 | Batch | 181007T001418Z | Neil |
| 012 | Charcoal | 181007T001145Z | Neil |
| 047 | Python 2 | 181006T231716Z | Chas Bro |
| 032 | Standard ML | 181006T222852Z | Laikoni |
| 003 | APLDyalog | 181006T162043Z | Quintec |
| 015 | R | 181006T165006Z | Kirill L |
| 009 | Perl 6 | 181006T163546Z | nwellnho |
| 027 | JavaScript ES6 | 181006T161621Z | Arnauld |
| 014 | Wolfram Language Mathematica | 181006T161452Z | Misha La |
| 003 | Jelly | 181006T160513Z | Erik the |
| 008 | Haskell | 181006T160448Z | nimi |
TI-BASIC (TI-83 Plus), 34 bytes
Input L₁
For(K,2,dim(L₁
L₁(K-1)L₁(K→L₁(K
End
L₁
type list as {1,2,3,4,5...
input a0 as the first element in the list
Desmos, 47 bytes
f(k,l)=∏_{n=1}^{[1...l.length+1]}join(k,l)[n]
MathGolf, 6 5 bytes
\{\o*
I think this could be 5 bytes ( This is now fixed in the latest version.\{\o*) but \ instruction seems a little off when dealing with input.
Explanation:
\ Swap arguments, pushing both to stack
{ Foreach loop over second argument
\o Output counter with newline
* Multiply counter by current element
Implicitly output the last element
J, 6 5 bytes
-1 byte thanks to Bubbler
*/\@,
Explanation:
A diadic verb, the left argument is a0, the rigth one - the vector
@, - append the vector to a0 and
*/\ - find the running product
dc, 13 bytes
p[*pz1<A]dsAx
p[*pz1<A]dsAx
p # Print the first element
*p # Multiply top elements on the stack
[ z1<A]dsAx # until only one element is left
PowerShell, 29 bytes
param($a,$b)$a;$b|%{($a*=$_)}
This assumes just outputting the values is fine.
> .\scratch.ps1 1 (1,5,3,2)
1
1
5
15
30
If that's not fine, this actually builds the list and then pushes it to toString which prints the same way.
param($a,$b)$c=,$a;$b|%{$c+=$_*$c[-1]};$c #41 bytes
MATL, 3 bytes
hYp
#implicit input, x_0 and A
h #horizontally concatenate
Yp #cumulative product
#implicit output
The hYpe about MATL is real.
K (oK), 9 bytes
{(*\)x,y}
Joins the first number to the second input as a list, and then returns successive results of multiplication
Test Cases
Enter your input after the function like below and then run, as I'm unsure how to use input properly for this language in TiO
{(*\)x,y}[1;1 5 3 2]
Python 2, 40 bytes
f=lambda a,b:[a]+(b and f(a*b[0],b[1:]))
Surprisingly, the move to Python 3 and use of generators there only saves 1 byte over the recursive solution.
Pyth, 6 bytes
*FR._s
Alternatively, 7 bytes:
.u*NYEQ
The first takes input as a tuple, the second takes input as two separate lines.
Thanks to @Sok for helping me with getting good at mapping and saving 1 byte.
05AB1E, 5 3 bytes
šηP
-2 bytes thanks to @BMO.
Try it online or verify all test cases.
Explanation:
š # Prepend the (implicit) input-integer at the start of the (implicit) input-list
# i.e. -12 and [7,-1,-12,4] → ["-12",7,-1,-12,4]
η # Prefixes of this new list
# i.e. ["-12",7,-1,-12,4]
# → [["-12"],["-12",7],["-12",7,-1],["-12",7,-1,-12],["-12",7,-1,-12,4]]
P # Take the product of each inner list (and output implicitly)
# i.e. [["-12"],["-12",7],["-12",7,-1],["-12",7,-1,-12],["-12",7,-1,-12,4]]
# → [-12,-84,84,-1008,-4032]
Husk, 2 bytes
G*
This is equivalent to nimi's answer in Haskell: scanl(*), which means reduce from the left using multiplication, and return all partial results.
Python 3, 39 bytes
def f(a,b):
for x in[1]+b:a*=x;yield a
Alternative approach. Returns a generator.
Common Lisp, 67 bytes
(lambda(a l &aux(y 1))(mapcar(lambda(x)(setf y(* y x)))(cons a l)))
Japt, 3 bytes
å*V
Explanation
:Implicit input of array U and integer V
å :Cumulatively reduce U
* :By multiplication
V :With an initial value of V
Batch, 69 bytes
@set/pa=
@echo %a%
@for %%d in (%*) do @set/aa*=%%d&call echo %%a%%
Takes input of \$a_0\$ on STDIN and the deltas as command-line arguments.
Charcoal, 12 bytes
IE⁺⟦N⟧AΠ⊞Oυι
Try it online! Link is to verbose version of code. Explanation:
N Input a₀
⟦ ⟧ Wrap in a list
A Input deltas as a list
⁺ Concatenate lists
E Map over elements
ι Current element
υ Predefined empty list variable
⊞O Push and return updated list
Π Product
I Cast to string
Implicitly print each value on its own line
Standard ML, 32 bytes
fun f(x::r)a=a::f r(a*x)|f&a=[a]
Ungolfed:
fun f (x::xr) a = a :: f xr (a*x)
| f _ a = [a]
APL(Dyalog), 3 bytes
×\∊
If I have to take the number on the left and the array on the right:
-2 thanks to @H.PWiz
7 5 3 bytes
×\,
R, 15 bytes
cumprod(scan())
Full program. Function is longer (unless we were allowed to "glue" the inputs together, so that built-in cumprod would suffice as a complete answer):
R, 28 bytes
function(i,x)cumprod(c(i,x))
Wolfram Language (Mathematica), 14 bytes
FoldList@Times
FoldList[Times, a0, {x1, x2, ..., xn}] produces the desired output. FoldList[Times] is the curried form that produces a pure function still waiting for its a0 and {x1, x2, ..., xn}.