| Bytes | Lang | Time | Link |
|---|---|---|---|
| 010 | Kona | 250116T155938Z | Abstract |
| 013 | Wolfram Language Mathematica | 241220T101601Z | Introduc |
| 030 | brainfuck | 241204T203200Z | Fmbalbue |
| 045 | Raku Perl 6 rakudo | 241211T200514Z | xrs |
| 005 | Uiua | 241210T134613Z | noodle p |
| 025 | Ruby | 241204T154639Z | Jordan |
| 064 | Tcl | 241209T022417Z | sergiol |
| 024 | Zsh +coreutils | 241208T023437Z | roblogic |
| 004 | Japt | 241207T224354Z | Shaggy |
| 035 | Python | 241204T124527Z | SectorCo |
| 035 | Forth gforth | 241206T071852Z | david |
| 009 | Charcoal | 241204T162709Z | Neil |
| 002 | 05AB1E | 241204T131131Z | Kevin Cr |
| 035 | Excel 365 | 241205T075036Z | Hand-E-F |
| 036 | PowerShell | 241204T164959Z | user3141 |
| 019 | Desmos | 241205T054337Z | Aiden Ch |
| 003 | Nekomata | 241205T035928Z | alephalp |
| 032 | JavaScript Node.js | 241205T023635Z | l4m2 |
| 017 | Octave | 241205T022005Z | tsh |
| 015 | R | 241205T000652Z | Eonema |
| 057 | Nim | 241204T175010Z | Qaziquza |
| 027 | Bash + common utilities | 241204T171802Z | Digital |
| 030 | AWK | 241204T170422Z | xrs |
| 033 | JavaScript ES6 | 241204T131024Z | Arnauld |
| 019 | Haskell + hgl | 241204T145248Z | corvus_1 |
| 006 | APL+WIN | 241204T144834Z | Graham |
| 036 | C# Visual C# Interactive Compiler with /uSystem.Linq.Enumerable flag | 241204T133249Z | Kevin Cr |
| 003 | Vyxal 3 | 241204T124857Z | pacman25 |
| 005 | APL Dyalog 20.0 | 241204T122839Z | Adá |
brainfuck, 43, 30 bytes
,>,>,[-<<[-<+>>+<]<[->+<]>>.>]
Takes M, C, V in ascii ordinals, some if not most implementations use unicode ordinals.
Doesn't work in floats.
Thanks to @WeirdGlyphs for -13 bytes. Also, this user gave me the explanation for the code.
Explanation:
,>,>, take (M C V)
[ while V != 0:
- V minus 1
<<[ while M != 0:
-<+>>+<] M minus 1; temp plus 1; C plus 1
<[->+<] M = temp; temp = 0
>>.>] print(C)
Zsh +coreutils, 24 bytes
echo $1\*{1..$3}+$2\;|bc
There's also a short solution using jot and setopt force_float but that would be unoriginal.
Python, 40 39 35 bytes
lambda M,C,V:[C:=C+A for A in[M]*V]
-1 byte by tsh
-4 bytes by Albert.Lang
Forth (gforth), 35 bytes
: a 0 DO 2DUP OVER I * + + . LOOP ;
Just works with integers, not with floats. Modifies global integer stack state.
Charcoal, 9 bytes
I⁺×…·¹NNN
Try it online! Link is to verbose version of code. Takes input in the order V, M, C. Explanation: Forms a range from 1 to V, vectorised multiplies it by M and vectorised adds C.
6 bytes by requiring input in JSON format:
I⁺×⊕…N
Try it online! Takes input in the order V, M, C. Explanation: Forms a range from 0 to V-1, increments it, then vectorised multiplies it by M and vectorised adds C.
05AB1E, 3 2 bytes
Lβ
Two loose inputs in the order and format \$V\$ and \$[M,C]\$.
Try it online or verify all test cases.
Explanation:
L # Push a list in the range [1, first (implicit) input V]
β # Convert the second (implicit) input-pair [M,C] from a base-v list to a
# base-10 integer for each v in the [1,V]-ranged list
# (after which this list is output implicitly)
Excel 365, 35 bytes
Input M, C, V into A1:C1.
In any other cell, write the formula:
=MAKEARRAY(C1,,LAMBDA(x,y,x*A1+B1))
PowerShell, 36 bytes
iex('1..{2}|%{{{0}*$_+{1}}}'-f$args)
The obvious solution would be something like for($i=1;$i-le$args[2];$i++){$args[0]*$i+$args[1]} for a whopping 50 bytes, mainly due to the $args elements.
Using iex (an alias for Invoke-Expression, which interprets a string as PowerShell), and the format operator -f, allows to golf 14 bytes from that.
Slightly ungolfed:
'1..{2} | % {{ {0} * $_ + {1} }}' -f $args
$args is an array which contains the three input values; they will be inserted into the string at {0}, {1}, {2}, respectively (the double {{ and }} escape the curly brackets required for the loop).
So with 2, 0, 5 as input, that would create the string
1..5 | % { 2 * $_ + 0 }
% is an alias for ForEach-Object, and $_ is the loop variable.
iex will then run this string as PowerShell.
Output is implicit.
Desmos, 19 bytes
f(m,c,v)=[1...v]m+c
What better way to solve a "graphing" calculator problem... than to literally use a graphing calculator!
AWK, 30 bytes
{for(;i++<$3;)printf$1*i+$2FS}
{for(;i++<$3;) # increment to V
printf # print Y
$1*i+$2 # MX+C
FS} # space between numbers
JavaScript (ES6), 33 bytes
Expects (m)(c)(v) and returns an array of floats.
m=>c=>g=v=>v?[...g(v-1),m*v+c]:[]
Commented
m => // 1st function taking m
c => // 2nd function taking c
g = v => // g = recursive function taking v
v ? // if v is not 0:
[ // update the output array:
...g(v - 1), // append the result of a recursive call with v-1
m * v + c // followed by the current value m*v+c
] // end of array
: // else:
[] // stop the recursion
APL+WIN, 6 bytes
Prompts for input of v followed by m and then c
⎕+⎕×⍳⎕
C# (Visual C# Interactive Compiler) with /u:System.Linq.Enumerable flag, 36 bytes
(m,c,v)=>Range(1,v).Select(i=>m*i+c)
Explanation:
(m,c,v)=> // Method with two double and one integer inputs
// and IEnumerable<double> return-type
Range(1,v) // Create an IEnumerable in the range [1,v]
.Select(i=> // Map each value `i` to:
m*i+c) // Multiply `m` by `i` and add `c`
APL (Dyalog 20.0), 5 bytes
Anonymous tacit infix function, taking V as left argument and [M,C] as right argument.
⍪⍤⍳⍛⊥
Try it online! (emulation due to old TIO version)
…⍛⊥ evaluate in mixed-base, but first pre-process the left argument as follows:
…⍤⍳ expanding to the indices 1…V, and then:
⍪ transform into a column vector (matches up the entire [M,C] with each of 1…V)