text:
The Woz Monitor
 Challenge
I've recently gotten into 8-bit computers and are fascinated with the workings of them and others alike; thus the objective of this code golf, is to replicate a portion of the Woz Monitor, designed by Steve Wozniak for the Apple I.
You are to store an array of 22 hexadecimal values with a width of two bytes, (min value $10, max value $FF), and then take in n-amount of inputs. (Normally two; languages like Brainfuck might have a hard time).
The inputs will refer to where in the array to start printing from, and where to stop; an input with defined behaviour will have their starting value less or equal to the ending value. Your program must then be capable of printing every hexadecimal value between, and including, the hexadecimals inputted.
An example of this:
Array
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15

Values
FF F4 B6 D7 40 00 00 A4 F0 00 FF 0D 9C 21 65 C4 02 28 90 E7 D6 A5

input first num:
04
input second num:
14
40 00 00 A4 F0 00 FF 0D 9C 21 65 C4 02 28 90 E7 D6

Now the interesting part of this exercise, is that you can use whatever you want to check the bounds of the users input. Person inputs hello and your program has undefined behaviour? It quits without notice? They are both valid.
The only rules are:
1. You must include the values of the 22 hexadecimal values as part of your program before it starts, (can't ask the user for inputs).
2. The output of the hexadecimal values must follow the exact format:
    00 FF 00 FF 00 Trailing spaces, tabs or lines are OK. Characters are not.
3. The program doesn't have to ask for the inputs with a message. Leave the "message" blank if you wish. The user must input the hex-bounds however.
4. As with the values of the 22 hexadecimals are up to you to decide, you must make a program that actually fetches the values from storage, opposed to mimicking a program by simply printing values. (such as a list of $00's).
5. n-amount of inputs, refers to the amount of inputs required for your language of choice to recognise a hexadecimal of two byte-width. eg. (Brainfuck will require two inputs per hex, making it four for the two).
Feel free to comment if you need clarification.
This is code golf, so the shortest answer in the number of bytes is the winner.
 Leaderboard
Here is a leaderboard generating snippet courtesy of Martin Ender.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
# Ruby, <s>104</s> <s>101</s> 96 bytes

function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/95080/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){$.ajax({url:answersUrl(page++),method:"get",dataType:"jsonp",crossDomain:true,success:function(e){answers.push.apply(answers,e.items);if(e.has_more)getAnswers();else process()}})}function shouldHaveHeading(e){var t=false;var n=e.body_markdown.split("\n");try{t|=/^#/.test(e.body_markdown);t|=["-","="].indexOf(n[1][0])>-1;t&=LANGUAGE_REG.test(e.body_markdown)}catch(r){}return t}function shouldHaveScore(e){var t=false;try{t|=SIZE_REG.test(e.body_markdown.split("\n")[0])}catch(n){}return t}function getAuthorName(e){return e.owner.display_name}function process(){answers=answers.filter(shouldHaveScore).filter(shouldHaveHeading);answers.sort(function(e,t){var n=+(e.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0],r=+(t.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0];return n-r});var e={};var t=0,c=0,p=-1;answers.forEach(function(n){var r=n.body_markdown.split("\n")[0];var i=$("#answer-template").html();var s=r.match(NUMBER_REG)[0];var o=(r.match(SIZE_REG)||[0])[0];var u=r.match(LANGUAGE_REG)[1];var a=getAuthorName(n);t++;c=p==o?c:t;i=i.replace("{{PLACE}}",c+".").replace("{{NAME}}",a).replace("{{LANGUAGE}}",u).replace("{{SIZE}}",o).replace("{{LINK}}",n.share_link);i=$(i);p=o;$("#answers").append(i);e[u]=e[u]||{lang:u,user:a,size:o,link:n.share_link}});var n=[];for(var r in e)if(e.hasOwnProperty(r))n.push(e[r]);n.sort(function(e,t){if(e.lang>t.lang)return 1;if(e.lang<t.lang)return-1;return 0});for(var i=0;i<n.length;++i){var s=$("#language-template").html();var r=n[i];s=s.replace("{{LANGUAGE}}",r.lang).replace("{{NAME}}",r.user).replace("{{SIZE}}",r.size).replace("{{LINK}}",r.link);s=$(s);$("#languages").append(s)}}var QUESTION_ID=49042;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var answers=[],page=1;getAnswers();var SIZE_REG=/\d+(?=[^\d&]*(?:<(?:s>[^&]*<\/s>|[^&]+>)[^\d&]*)*$)/;var NUMBER_REG=/\d+/;var LANGUAGE_REG=/^#*\s*([^,]+)/
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<link rel=stylesheet type=text/css href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	AuthorLanguageSize

Winners by Language

LanguageUserScore

{{PLACE}}	{{NAME}}{{LANGUAGE}}{{SIZE}}Link

{{LANGUAGE}}{{NAME}}{{SIZE}}Link

Are we asking the user for two inputs or n? Do we choose what the 22 hex values are?

Yes, the 22 values are yours to decide. The input values, they can be any amount. I said n because Brainfuck can't take in a 2 character string, you would need to input the first byte, then the second for the first value, and then do it again for the second value, 4 inputs in total. They can be however many as you like.

However with the values, you can't simply have them all as 00, and have a program mimic what something would that actually reads the arrays. Updating the question.

Should it wrap or read in reverse if input 2 is less than input 1?

@JonathanAllan That is entirely up to you. Just remember, making sure the inputs are correct may make your code bigger. As written just above the rules, you can allow any form of input (up to you), leading to undefined behaviour or errors if you wish.

@Arnauld :O My calculator wronged me! Should of checked that myself. :/ Still 22 values! Edited the question.

Is lowercase hexa allowed? (0a, 0b, etc.)

@Arnauld Whatever you want. :)

Let us continue this discussion in chat.

"the amount of inputs required for your language of choice to recognise a hexadecimal of two byte-width" why exactly? If the inputs are 0 to 22, the width is only 5 bits.

@PeterTaylor No, thats how many values you have. The values themselves must be two bytes wide, between $100 and $FFF.

Is a single leading space allowed?

Can the values be randomly chosen at the beginning? Meaning for consecutive runs you get a different answers?

@carusocomputing Yes it can! As long as you end up with sixteen 2 byte-wide values.

Does it have to be STDIN or can we just take two command line arguments? 2. I guess you mean two digits, not two bytes ... but 3. How do 00, 02 and 0D from your example fit in there? 4. And how does that match your answer from Oct, 2 betweeen $100 and $FFF?

@Titus 1. Go for it. Command line arguments it is. 2. Nope, two bytes. The 'digits' you see are the hex representation. Woz monitor worked specifically in bytes. 3. I'm not sure what your asking but if it is what I think it is, your going to need to display 16 bytes as a 2-byte-wide hex value. The 00, 02 and 0D are locations in an array (0, 2 and 13 respectively). Each location will correspond to a random 2-byte-wide value in the array. 4. If you mean between $10 and $FF, its literally a Python translation of the same thing in my C answer. I chose the easy way by making everything-

@Titus -$00 and afterwards just fetch each of them from their corresponding array index.

@Titus Woops, thats 22 bytes, not 16!

Jelly, 24 21 bytes
w@€ØHḅ⁴
ɠÇµɠÇr@b⁴ịØHK

Chosen values: [00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 1F 10 11 12 13 14 15]
TryItOnline
If the second input is less than the first it outputs the reversed sequence.
Out of bounds behaviour is undefined (e.g. "foo", "14" returns 38 values, most of which are not even in the array and many of which are not length 2)
How?
w@€ØHḅ⁴ - Link 1, parse a string as a 1-based hex value e.g. "14"
w@€      - first index (1-based) of each character in
   ØH    - hex digits: "0123456789ABCDEF"                   [2,5]
     ḅ⁴ - convert from base 16                                 37

ɠÇµɠÇr@b⁴ịØHK - Main link
ɠ  ɠ          - read a line from stdin               e.g. "04"  "14"
 Ç  Ç         - call the last link (1) as a monad          21    37
  µ           - monadic chain separation
     r@       - inclusive range, with reversed arguments  [   21,   22,...,   36,   37]
       b⁴     - convert to base 16                        [[1,5],[1,6],...,[2,4],[2,5]]
         ị    - index into
          ØH  - hex digits: "0123456789ABCDEF"            [ "04", "05",..., "13", "14"]
            K - join with spaces

Ah, pardon me. You were indeed correct. Well done, and have leaderboard position #1. :)

yes, I just moved and changed the one offset value (now 1F), meaning I did not need to "correctly" interpret the hex inputs or add 16 to give me two hex digits to convert back.

JavaScript (ES6), 118 115 112 102 82 81 bytes
Saved 1 byte thanks to ETHproductions
Chosen values:
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15
-----------------------------------------------------------------
10 10 11 14 10 10 15 15 11 14 10 10 15 15 11 14 10 10 15 15 10 11

Prompts for the lower bound, then for the upper bound (e.g. 0x04 / 0x0f).
An invalid lower bound will be interpreted as 0x00 (minimum value).
An invalid upper bound will be interpreted as 0x15 (maximum value).
Outputs nothing if the lower bound is greater than the upper bound.

alert((1/7+'789').replace(/./g,(v,i)=>ib?'':(v|10)+' ',p=prompt,b=p(a=p())))

Previous version (97 bytes)
Generating a pseudo-random list of 'true' hexadecimal values:
alert((1/7+'789').replace(/./g,(v,i)=>ib?'':(v*7|16).toString(16)+' ',p=prompt,a=p(),b=p()))

Sequence:
10 10 17 1c 1e 38 33 31 17 1c 1e 38 33 31 17 1c 1e 38 33 31 38 3f

"message": "Uncaught SyntaxError: Invalid destructuring assignment target"

@frayment - This is Chrome, right? That's weird because it doesn't complain about [a,b]=prompt().split(' ') in the command line. Anyway, my updated answer should fix that.

Well done! Works now. Thats weird that Chrome does it. I tested it on your JS tester, and in my Developer console. Same error. Welcome to the leaderboard.

You could save some bytes with inputs like 0x04

@Hedi - I was actually editing my answer accordingly when you posted your comment. :-) However, the challenge says "recognize a hexadecimal", so I'm not sure if we're allowed to do so.

It doesn't need to recognise the decimal. It can automatically assume a user is inputting a decimal, so you don't have to check if they didn't. That is undefined behaviour and can simply be ignored like the rules state.

Also check my answer in C, I don't bother checking for cast-errors.

@frayment Would list of values be fine ? 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25
If it is then ++i*83&255 could be replaced by 16+i

@Hedi As long as there are only 22 values, they can be anything in your wildest imagination.

Dude, theres nothing wrong with your alternate, it works fine here and is within the rules. Update your post! :)

You can probably do b=p(a=p()) to save a byte.

JavaScript (ES6), 107 152 137 bytes
p=prompt,f=(a=+p(),b=+p(),[x,y,...s]='FFF4B6D7402011A4F0D0FF3D9C2165C4A22890E7D6A5')=>a?f(a-1,b-1,s):x+y+' '+(b?f(a,b-1,s):'');alert(f())

var
   p=prompt,f=(a=+p(),b=+p(),[x,y,...s]='FFF4B6D7402011A4F0D0FF3D9C2165C4A22890E7D6A5')=>a?f(a-1,b-1,s):x+y+' '+(b?f(a,b-1,s):'');alert(f())
;

//input 0x04 then 0x14 will print 40 to D6
//input 0x00 then 0x00 will print FF
//input 0x13 then 0x17 will print E7 D6 A5 NaN NaN

Chosen values:
FF F4 B6 D7 40 20 11 A4 F0 D0 FF 3D 9C 21 65 C4 A2 28 90 E7 D6 A5

Inputs:

Input format is 0x14
If any input is negative or the 1st input is greater than the 2nd : InternalError: too much recursion
Will print NaN for out of bounds.

Previous solutions:
152 bytes:
i=parseInt,p=prompt,f=(a=i(p()),b=i(p()),[x,y,...s]='FFF4B6D7402011A4F0D0FF3D9C2165C4A22890E7D6A5')=>a?f(a-1,b-1,s):x+y+' '+(b?f(a,b-1,s):'');alert(f())

107 bytes, invalid solution (inputs missing):
f=(a,b,[x,y,...s]='FFF4B6D7402011A4F0D0FF3D9C2165C4A22890E7D6A5')=>a?f(a-1,b-1,s):x+y+' '+(b?f(a,b-1,s):'')

Close! But you need to be able to ask the user for input. I like what you did with console.log(...) though. ;)

@frayment var  and the last ; are not part of the answer. Its just for the snippet, that's why I added linebreak. I'll edit the answer.

My bad @Hedi, sorry about that.

Python, 88 87 86 bytes
1 byte save thanks to @JonathanAllan
1 byte save again to @JonathanAllan
Also changed the base of the code, much nicer now.
a,b=[int(x,16)for x in raw_input().split()];l=[0]*22
while a<=b:print"%02x"%l[a],;a+=1

Chosen values: 00 for everything.
Same idea as my C answer. This time however, the code takes a single input from the user, requiring a space between both values, split them, cast them to hex values, and print every hex in the l array including and between the two inputted values. Since Python has a magnificent error-catching system, no buffer overflows are present and the code is therefore much more secure. The program is safe from undefined behaviour in a sense that it will not execute when a higher value is submitted before a lower value.
This should work on both Python 2.x and 3.x; Please correct me if I am wrong, as I don't have access to both interpreters due to my system not supporting both of them.

C, 176 175 161 bytes
1 byte save thanks to @JonathanAllan
Massive help thanks to @Downvoter for saving me 14 bytes!
int main(){int a[44]={0};char s[2];scanf("%s",s);int b=(int)strtol(s,0,16);scanf("%s",s);int c=(int)strtol(s,0,16);while(b<=c){printf("%d%d ",a[b],a[b+1]);b++;}}

Try it online!
Chosen values: 00 for everything.
Un-golfed answer:
int main() {
    int a[44] = {0};
    char s[2];
    scanf("%s", s);
    int b = (int) strtol(s, 0, 16);
    scanf("%s", s);
    int c = (int) strtol(s, 0, 16);
    while (b <= c) {
        printf("%d%d ", a[b], a[b+1]);
        b++;
    }
}

The trick to this, is taking in two inputs and attempting to convert them to hexadecimal strings and then cast to integers. Since there is no error-checking or anything likewise, undefined behaviour is simply throwing errors and breaking the program.
The user needs to enter two inputs, however my Eclipse CDT compiler seems to let me input them both on the same line with a space between.
They must be in the correct order, as requesting a bigger value before a smaller value will not run the while-loop at all.
The thing is, there is also no buffer-overflow protection, so I can simply request something absurd such as a range from $0 to $FFFF, and I will get everything in my computers memory from the beginning of the allocation of memory for the a[44] array, all the way to 65536 values later.

A single whitespace character in the input format matches any amount of whitespace in the input stream, although most scanf formats skip whitespace anyway, speaking of which, why not cut out the middle man and use %x directly?

Why not use char s[2] instead of the malloc stuff? Casting malloc's return value isn't necessary in C anyway.

@Neil If your talking about the printf("%d%d ", ...) part, by replacing the formatting with simply %x only returns 0's instead of 00's, and doesn't space them out.

@Downvoter Thankyou very much! I didn't think of that. Editing answer now.

No, I'm still talking about the scanf.

PHP, 106 105 104 96+2 bytes
eval($s='for($a=a;$a++<c;)$$a=hexdec($argv[++$i]);while($b<=$c)printf("%02X ",ord($s[$b++]));');

or
eval($s='for($a=a;$a++<c;)$$a=hexdec($argv[++$i]);');while($b<=$c)printf("%02X ",ord($s[$b++]));

Run with php -nr '' <lowindex> <highindex>; escape the single quotes in the code.
... or test it online.
dechex interpretes input as hexadecimal strings as far as characters are hex digits,
0 if the input starts with something else.
prints nothing if first value is larger than second.
chosen values:
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15
-----------------------------------------------------------------
66 6F 72 28 24 61 3D 61 3B 24 61 2B 2B 3C 63 3B 29 24 24 61 3D 68

(first 22 ascii codes of the executed code)
or
for($a=a;$a++<c;)eval($s='$$a=hexdec($argv[++$i]);');while($b<=$c)printf("%02X ",ord($s[$b++]));

with these values:
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15
-----------------------------------------------------------------
24 24 61 3D 68 65 78 64 65 63 28 24 61 72 67 76 5B 2B 2B 24 69 5D

Do answers normally incorporate the <?php chunk?

@frayment not if you use -r. And if I need to store it to a file, I use the short open tag <?.

Constants a, z, and ProgramingPuzles_CGolf are undefined. Where did ProgramingPuzles_CGolf come from anyway? :/

@frayment Those are notices. Reroute stderr to /dev/null if you don´t like them. PHP evaluates the undefined constants to strings.

But their coming up as Syntax Errors, I can't run the program.

@frayment: what PHP version? Try putting them in double quotes.

PHP 7.0 I'll try later, going out right now.

Perl, 79 45 41 bytes
"min value $10" - the example has minimum of $00- is that a typo?
Here's a rather boring perl answer in 41 bytes (Was 46 and then I kept seeing spaces, parens I could elide). Takes input in two lines.
printf'%02X ',$_ for(4..26)[hex<>..hex<>]

The data is a list 04..1A
Before I was being too clever with pack & unpack. Its input bytes are entered at once smushed together, eg "020E' will print the 2nd-14th entries
printf'%02X ',$_ for sub{(4..26)[shift..shift]}->(unpack'CC',pack'H4',<>)

Might try golfing it more using all 0's, substr, and printf'%*vX' ... nope that is making my answer longer. 48 characters (using a string of ascii '7', hex 37 as the data)
printf'%*vX',' ',substr 7x22,$s=hex<>,1+hex<>-$s

Scala, 45 bytes
(_:Int)to(_:Int)map(x=>f"$x%02X")mkString " "

Ungolfed:
(a:Int,b:Int)=>a.to(b).map(x=>f"$x%02X").mkString(" ")

Uses 00 to FF as values, but works up to 2147483647.

error: ')' expected but string literal found. at a.to(b).map(

Don't know if it's just me or what. :/ What should I try running it in?

@frayment that's probably because of the string interpolation, which were introduced in Scala 2.10.0

So which version did you build this in? 2.9?

@frayment I used the 2.11.7 REPL

C++, 98 95 93 bytes
#include <iostream>
int _[22],a,b;int main(){for(std::cin>>a>>b;b/a++;)printf("%02x ",_[a]);}

My chosen values are all 0's

Welcome to Programming Puzzles & Code Golf! This is a well-golfed answer, but I don't think it meets the requirements of the challenge. Would you mind including your 22 chosen hexadecimal values?

Nearly there! The only problem is, when I entered values 04 and 06, I only got two values back. I'm suspecting these are the 05 and 06 values. You need to provide all values between and including the inputted values.

@frayment, oh that's right, fixed it!

CJam, 22 bytes
{r:~Gb}2*37m!s2/\)<>S*

Chosen values:
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15
-----------------------------------------------------------------
13 76 37 53 09 12 26 34 50 46 31 59 79 58 15 80 90 24 00 00 00 00

Try it online

GNU sed, 209 + 1(r flag) = 210 bytes
1{h
s:.*:,00 FF,01 F4,02 B6,03 D7,04 40,05 00,06 00,07 A4,08 F0,09 00,0A FF,0B 0D,0C 9C,0D 21,0E 65,0F C4,10 02,11 28,12 90,13 E7,14 D6,15 A5:
H;d}
G;s:\n(.*)\n.*(,\1.*):\n\2:
s:(.*)\n(.*,\1 ..).*:\2:
s:,..::g

Try it online! One leading space is present in the output, I hope it's allowed.
Run examples:
me@LCARS:/PPCG$ echo -e "06\n0F" | sed -rf table_lookup.sed
 00 A4 F0 00 FF 0D 9C 21 65 C4
me@LCARS:/PPCG$ echo -e "13\n13" | sed -rf table_lookup.sed
 E7

Explanation: the 22 hexadecimal values stored are the same as the ones from the OP's example
value | FF F4 B6 D7 40 00 00 A4 F0 00 FF 0D 9C 21 65 C4 02 28 90 E7 D6 A5
-------------------------------------------------------------------------
index | 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15

The start and end indexes are read on separate lines. The output is a single line with the table values in that index range (inclusive). Undefined input will write multiple lines of invalid output.
# store START index in hold space
1{h
# generate the table
s:.*:,INDEX1 VALUE1,INDEX2 VALUE2,°°°:
# append table to hold space and delete pattern space
H;d}
# read END index, append hold space (pattern space format is: END\nSTART\nTABLE)
G
# delete table entries up to, but excluding, the START index (END\nTABLE')
s:\n(.*)\n.*(,\1.*):\n\2:
# delete table entries starting from, but excluding, the END index (TABLE'')
s:(.*)\n(.*,\1 ..).*:\2:
# remove the indexes and print (implicitly) the resulting values
s:,..::g

Apple II 6502 assembly, 75 bytes
Byte code:
A9 46 85 36 A9 10 85 37 A0 00 98 20 DA FD A9 A0
20 ED FD C0 42 D0 F3 20 93 FE A2 FC 20 1B FD 9D
04 01 E8 D0 F7 86 31 A9 8D 8D 04 02 20 A7 FF B5
3C 0A 75 3C 95 3C CA 10 F6 A6 3D BD 05 02 20 ED
FD E8 E4 3C D0 F5 99 05 02 C8 60
Disassembly:
  LDA    #<+
  STA    CSWL
  LDA    #>+
  STA    CSWH    ;redirect stdout
  LDY    #$00
- TYA
  JSR    PRBYTE  ;print number
  LDA    #$A0    ;space
  JSR    COUT    ;print space
  CPY    #$42    ;22*3
  BNE    -
  JSR    SETVID  ;restore stdout
  LDX    #$FC
- JSR    KEYIN   ;fetch a key
  STA    $0104,X ;store to $200+
  INX
  BNE    -       ;four keys
  STX    MODE    ;set internal flags
  LDA    #$8D
  STA    $0204   ;set key delimiter
  JSR    GETNUM  ;convert keys to hex values
- LDA    A1L,X   ;fetch value
  ASL
  ADC    A1L,X   ;multiply by 3
  STA    A1L,X   ;store value
  DEX
  BPL    -       ;both inputs
  LDX    A1H     ;first input
- LDA    $0205,X ;fetch from index
  JSR    COUT    ;print character
  INX
  CPX    A1L
  BNE    -       ;until second input
+ STA    $0205,Y ;fall through to save a byte
  INY
  RTS
It forms an array in memory that looks like the output.
The chosen values are:
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15
-----------------------------------------------------------------
00 03 06 09 0C 0F 12 15 18 1B 1E 21 24 27 2A 2D 30 33 36 39 3C 3F
User presses four keys to set the inputs.

Oooo using Apples own code. Very nicely done.


text:
The Colossal Gosper curve
Task
Produce this 24kB ASCII art output:
                                                                          ________
                                                                          \       \
                                                                ________   \____   \                                                                ________
                                                                \       \      /   /                                                                \       \
                                                                 \____   \____/   /   ____                                                ________   \____   \
                                                                     /            \   \   \                                               \       \      /   /
                                                                ____/   ________   \   \   \        ________                               \____   \____/   /   ____
                                                               /        \       \   \  /   /        \       \                                  /            \   \   \
                                                              /   ____   \____   \   \/   /   ____   \____   \                            ____/   ________   \   \   \        ________
                                                              \   \   \      /   /        \  /   /       /   /                           /        \       \   \  /   /        \       \
                                                    ________   \   \   \____/   /   ____   \/   /   ____/   /   ____                    /   ____   \____   \   \/   /   ____   \____   \
                                                    \       \   \  /            \  /   /       /   /        \   \   \                   \   \   \      /   /        \  /   /       /   /
                                          ________   \____   \   \/   ________   \/   /   ____/   /   ____   \   \   \        ________   \   \   \____/   /   ____   \/   /   ____/   /   ____
                                          \       \      /   /        \       \      /   /        \   \   \   \  /   /        \       \   \  /            \  /   /       /   /        \   \
                                           \____   \____/   /   ____   \____   \____/   /   ____   \   \   \   \/   /   ____   \____   \   \/   ________   \/   /   ____/   /   ____   \   \
                                               /            \   \   \      /            \   \   \   \  /   /        \  /   /       /   /        \       \      /   /        \   \   \   \  /
                                          ____/   ________   \   \   \____/   ________   \   \   \   \/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \   \   \   \/
                                         /        \       \   \  /            \       \   \  /   /        \  /   /       /   /        \  /   /       /            \   \   \   \  /   /
                                        /   ____   \____   \   \/   ________   \____   \   \/   /   ____   \/   /   ____/   /   ____   \/   /   ____/   ________   \   \   \   \/   /   ____
                                        \   \   \      /   /        \       \      /   /        \   \   \      /   /        \  /   /       /   /        \       \   \  /   /        \  /   /
                                         \   \   \____/   /   ____   \____   \____/   /   ____   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \   \/   /   ____   \/   /
                                          \  /            \  /   /       /            \   \   \   \  /            \   \   \      /   /        \  /   /       /   /        \   \   \      /
                                           \/   ________   \/   /   ____/   ________   \   \   \   \/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \   \   \____/
                                                \       \      /   /        \       \   \  /   /        \       \   \  /            \  /   /       /   /        \   \   \   \  /
                                                 \____   \____/   /   ____   \____   \   \/   /   ____   \____   \   \/   ________   \/   /   ____/   /   ____   \   \   \   \/   ________
                                                     /            \   \   \      /   /        \  /   /       /   /        \       \      /   /        \   \   \   \  /   /        \       \
                                                ____/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \   \   \   \/   /   ____   \____   \
                                               /        \       \   \  /            \  /   /       /   /        \  /   /       /            \   \   \   \  /   /        \  /   /       /   /
                                              /   ____   \____   \   \/   ________   \/   /   ____/   /   ____   \/   /   ____/   ________   \   \   \   \/   /   ____   \/   /   ____/   /   ____
                                              \  /   /       /   /        \       \      /   /        \  /   /       /   /        \       \   \  /   /        \  /   /       /   /        \  /   /
                                               \/   /   ____/   /   ____   \____   \____/   /   ____   \/   /   ____/   /   ____   \____   \   \/   /   ____   \/   /   ____/   /   ____   \/   /
                                                   /   /        \   \   \      /            \   \   \      /   /        \  /   /       /   /        \   \   \      /   /        \  /   /       /
                                              ____/   /   ____   \   \   \____/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \   \   \____/   /   ____   \/   /   ____/
                                             /        \   \   \   \  /            \       \   \  /            \  /   /       /   /        \   \   \   \  /            \   \   \      /   /
                                            /   ____   \   \   \   \/   ________   \____   \   \/   ________   \/   /   ____/   /   ____   \   \   \   \/   ________   \   \   \____/   /   ____
                                            \   \   \   \  /   /        \       \      /   /        \       \      /   /        \   \   \   \  /   /        \       \   \  /            \  /   /
                                  ________   \   \   \   \/   /   ____   \____   \____/   /   ____   \____   \____/   /   ____   \   \   \   \/   /   ____   \____   \   \/   ________   \/   /
                                  \       \   \  /   /        \  /   /       /            \   \   \      /            \   \   \   \  /   /        \  /   /       /   /        \       \      /
                        ________   \____   \   \/   /   ____   \/   /   ____/   ________   \   \   \____/   ________   \   \   \   \/   /   ____   \/   /   ____/   /   ____   \____   \____/
                        \       \      /   /        \   \   \      /   /        \       \   \  /            \       \   \  /   /        \  /   /       /   /        \   \   \      /
                         \____   \____/   /   ____   \   \   \____/   /   ____   \____   \   \/   ________   \____   \   \/   /   ____   \/   /   ____/   /   ____   \   \   \____/   ________
                             /            \   \   \   \  /            \   \   \      /   /        \       \      /   /        \   \   \      /   /        \   \   \   \  /            \       \
                        ____/   ________   \   \   \   \/   ________   \   \   \____/   /   ____   \____   \____/   /   ____   \   \   \____/   /   ____   \   \   \   \/   ________   \____   \
                       /        \       \   \  /   /        \       \   \  /            \  /   /       /            \   \   \   \  /            \   \   \   \  /   /        \       \      /   /
                      /   ____   \____   \   \/   /   ____   \____   \   \/   ________   \/   /   ____/   ________   \   \   \   \/   ________   \   \   \   \/   /   ____   \____   \____/   /   ____
                      \   \   \      /   /        \  /   /       /   /        \       \      /   /        \       \   \  /   /        \       \   \  /   /        \  /   /       /            \   \   \
            ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \____   \   \/   /   ____   \____   \   \/   /   ____   \/   /   ____/   ________   \   \   \        ________
            \       \   \  /            \  /   /       /   /        \   \   \      /            \   \   \      /   /        \  /   /       /   /        \   \   \      /   /        \       \   \  /   /        \       \
  ________   \____   \   \/   ________   \/   /   ____/   /   ____   \   \   \____/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \   \   \____/   /   ____   \____   \   \/   /   ____   \____   \
  \       \      /   /        \       \      /   /        \   \   \   \  /            \       \   \  /            \  /   /       /   /        \   \   \   \  /            \   \   \      /   /        \  /   /       /   /
   \____   \____/   /   ____   \____   \____/   /   ____   \   \   \   \/   ________   \____   \   \/   ________   \/   /   ____/   /   ____   \   \   \   \/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____
       /            \   \   \      /            \   \   \   \  /   /        \       \      /   /        \       \      /   /        \   \   \   \  /   /        \       \   \  /            \  /   /       /   /        \  /   /
  ____/   ________   \   \   \____/   ________   \   \   \   \/   /   ____   \____   \____/   /   ____   \____   \____/   /   ____   \   \   \   \/   /   ____   \____   \   \/   ________   \/   /   ____/   /   ____   \/   /
 /        \       \   \  /            \       \   \  /   /        \  /   /       /            \   \   \      /            \   \   \   \  /   /        \  /   /       /   /        \       \      /   /        \  /   /       /
/   ____   \____   \   \/   ________   \____   \   \/   /   ____   \/   /   ____/   ________   \   \   \____/   ________   \   \   \   \/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \/   /   ____/
\   \   \      /   /        \       \      /   /        \   \   \      /   /        \       \   \  /            \       \   \  /   /        \  /   /       /   /        \  /   /       /            \   \   \      /   /
 \   \   \____/   /   ____   \____   \____/   /   ____   \   \   \____/   /   ____   \____   \   \/   ________   \____   \   \/   /   ____   \/   /   ____/   /   ____   \/   /   ____/   ________   \   \   \____/   /   ____
  \  /            \  /   /       /            \   \   \   \  /            \   \   \      /   /        \       \      /   /        \   \   \      /   /        \  /   /       /   /        \       \   \  /            \  /   /
   \/   ________   \/   /   ____/   ________   \   \   \   \/   ________   \   \   \____/   /   ____   \____   \____/   /   ____   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \   \/   ________   \/   /
        \       \      /   /        \       \   \  /   /        \       \   \  /            \  /   /       /            \   \   \   \  /            \   \   \      /   /        \  /   /       /   /        \       \      /
         \____   \____/   /   ____   \____   \   \/   /   ____   \____   \   \/   ________   \/   /   ____/   ________   \   \   \   \/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \____/
             /            \   \   \      /   /        \  /   /       /   /        \       \      /   /        \       \   \  /   /        \       \   \  /            \  /   /       /   /        \  /   /       /
        ____/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \____   \   \/   /   ____   \____   \   \/   ________   \/   /   ____/   /   ____   \/   /   ____/   ________
       /        \       \   \  /            \  /   /       /   /        \  /   /       /            \   \   \      /   /        \  /   /       /   /        \       \      /   /        \  /   /       /   /        \       \
      /   ____   \____   \   \/   ________   \/   /   ____/   /   ____   \/   /   ____/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \/   /   ____/   /   ____   \____   \
      \  /   /       /   /        \       \      /   /        \  /   /       /   /        \       \   \  /            \  /   /       /   /        \  /   /       /            \   \   \      /   /        \  /   /       /   /
       \/   /   ____/   /   ____   \____   \____/   /   ____   \/   /   ____/   /   ____   \____   \   \/   ________   \/   /   ____/   /   ____   \/   /   ____/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____
           /   /        \   \   \      /            \   \   \      /   /        \  /   /       /   /        \       \      /   /        \  /   /       /   /        \       \   \  /            \  /   /       /   /        \  /   /
      ____/   /   ____   \   \   \____/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \/   /   ____/   /   ____   \____   \   \/   ________   \/   /   ____/   /   ____   \/   /
     /        \   \   \   \  /            \       \   \  /            \  /   /       /   /        \   \   \      /            \   \   \      /   /        \  /   /       /   /        \       \      /   /        \  /   /       /
    /   ____   \   \   \   \/   ________   \____   \   \/   ________   \/   /   ____/   /   ____   \   \   \____/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \/   /   ____/
    \   \   \   \  /   /        \       \      /   /        \       \      /   /        \   \   \   \  /            \       \   \  /            \  /   /       /   /        \   \   \      /            \   \   \      /   /
     \   \   \   \/   /   ____   \____   \____/   /   ____   \____   \____/   /   ____   \   \   \   \/   ________   \____   \   \/   ________   \/   /   ____/   /   ____   \   \   \____/   ________   \   \   \____/   /   ____
      \  /   /        \  /   /       /            \   \   \      /            \   \   \   \  /   /        \       \      /   /        \       \      /   /        \   \   \   \  /            \       \   \  /            \  /   /
       \/   /   ____   \/   /   ____/   ________   \   \   \____/   ________   \   \   \   \/   /   ____   \____   \____/   /   ____   \____   \____/   /   ____   \   \   \   \/   ________   \____   \   \/   ________   \/   /
            \   \   \      /   /        \       \   \  /            \       \   \  /   /        \  /   /       /            \   \   \      /            \   \   \   \  /   /        \       \      /   /        \       \      /
             \   \   \____/   /   ____   \____   \   \/   ________   \____   \   \/   /   ____   \/   /   ____/   ________   \   \   \____/   ________   \   \   \   \/   /   ____   \____   \____/   /   ____   \____   \____/
              \  /            \   \   \      /   /        \       \      /   /        \   \   \      /   /        \       \   \  /            \       \   \  /   /        \  /   /       /            \   \   \      /
               \/              \   \   \____/   /   ____   \____   \____/   /   ____   \   \   \____/   /   ____   \____   \   \/   ________   \____   \   \/   /   ____   \/   /   ____/   ________   \   \   \____/
                                \  /            \  /   /       /            \   \   \   \  /            \   \   \      /   /        \       \      /   /        \   \   \      /   /        \       \   \  /
                                 \/   ________   \/   /   ____/   ________   \   \   \   \/   ________   \   \   \____/   /   ____   \____   \____/   /   ____   \   \   \____/   /   ____   \____   \   \/
                                      \       \      /   /        \       \   \  /   /        \       \   \  /            \  /   /       /            \   \   \   \  /            \   \   \      /   /
                                       \____   \____/   /   ____   \____   \   \/   /   ____   \____   \   \/   ________   \/   /   ____/   ________   \   \   \   \/   ________   \   \   \____/   /   ____
                                           /            \   \   \      /   /        \  /   /       /   /        \       \      /   /        \       \   \  /   /        \       \   \  /            \  /   /
                                      ____/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \____   \   \/   /   ____   \____   \   \/   ________   \/   /
                                     /        \       \   \  /            \  /   /       /   /        \   \   \      /            \   \   \      /   /        \  /   /       /   /        \       \      /
                                    /   ____   \____   \   \/   ________   \/   /   ____/   /   ____   \   \   \____/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \____/
                                    \  /   /       /   /        \       \      /   /        \   \   \   \  /            \       \   \  /            \  /   /       /   /        \   \   \      /
                                     \/   /   ____/   /   ____   \____   \____/   /   ____   \   \   \   \/   ________   \____   \   \/   ________   \/   /   ____/   /   ____   \   \   \____/
                                         /   /        \  /   /       /            \   \   \   \  /   /        \       \      /   /        \       \      /   /        \   \   \   \  /
                                    ____/   /   ____   \/   /   ____/   ________   \   \   \   \/   /   ____   \____   \____/   /   ____   \____   \____/   /   ____   \   \   \   \/
                                   /        \  /   /       /   /        \       \   \  /   /        \  /   /       /            \   \   \      /            \   \   \   \  /   /
                                  /   ____   \/   /   ____/   /   ____   \____   \   \/   /   ____   \/   /   ____/   ________   \   \   \____/   ________   \   \   \   \/   /   ____
                                  \   \   \      /   /        \  /   /       /   /        \   \   \      /   /        \       \   \  /            \       \   \  /   /        \  /   /
                                   \   \   \____/   /   ____   \/   /   ____/   /   ____   \   \   \____/   /   ____   \____   \   \/   ________   \____   \   \/   /   ____   \/   /
                                    \  /            \  /   /       /   /        \   \   \   \  /            \   \   \      /   /        \       \      /   /        \   \   \      /
                                     \/   ________   \/   /   ____/   /   ____   \   \   \   \/   ________   \   \   \____/   /   ____   \____   \____/   /   ____   \   \   \____/
                                          \       \      /   /        \   \   \   \  /   /        \       \   \  /            \  /   /       /            \   \   \   \  /
                                           \____   \____/   /   ____   \   \   \   \/   /   ____   \____   \   \/   ________   \/   /   ____/   ________   \   \   \   \/   ________
                                               /            \   \   \   \  /   /        \  /   /       /   /        \       \      /   /        \       \   \  /   /        \       \
                                          ____/   ________   \   \   \   \/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \____   \   \/   /   ____   \____   \
                                         /        \       \   \  /   /        \  /   /       /   /        \  /   /       /            \   \   \      /   /        \  /   /       /   /
                                        /   ____   \____   \   \/   /   ____   \/   /   ____/   /   ____   \/   /   ____/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____
                                        \  /   /       /   /        \   \   \      /   /        \  /   /       /   /        \       \   \  /            \  /   /       /   /        \  /   /
                                         \/   /   ____/   /   ____   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \   \/   ________   \/   /   ____/   /   ____   \/   /
                                             /   /        \   \   \   \  /            \   \   \      /   /        \  /   /       /   /        \       \      /   /        \  /   /       /
                                        ____/   /   ____   \   \   \   \/   ________   \   \   \____/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \/   /   ____/
                                       /        \   \   \   \  /   /        \       \   \  /            \  /   /       /   /        \   \   \      /            \   \   \      /   /
                                      /   ____   \   \   \   \/   /   ____   \____   \   \/   ________   \/   /   ____/   /   ____   \   \   \____/   ________   \   \   \____/   /   ____
                                      \   \   \   \  /   /        \  /   /       /   /        \       \      /   /        \   \   \   \  /            \       \   \  /            \  /   /
                                       \   \   \   \/   /   ____   \/   /   ____/   /   ____   \____   \____/   /   ____   \   \   \   \/   ________   \____   \   \/   ________   \/   /
                                        \  /   /        \  /   /       /   /        \   \   \      /            \   \   \   \  /   /        \       \      /   /        \       \      /
                                         \/   /   ____   \/   /   ____/   /   ____   \   \   \____/              \   \   \   \/   /   ____   \____   \____/   /   ____   \____   \____/
                                              \   \   \      /   /        \   \   \   \  /                        \  /   /        \  /   /       /            \   \   \      /
                                               \   \   \____/   /   ____   \   \   \   \/                          \/   /   ____   \/   /   ____/   ________   \   \   \____/
                                                \  /            \   \   \   \  /   /                                    \   \   \      /   /        \       \   \  /
                                                 \/              \   \   \   \/   /   ____                               \   \   \____/   /   ____   \____   \   \/
                                                                  \  /   /        \  /   /                                \  /            \   \   \      /   /
                                                                   \/   /   ____   \/   /                                  \/              \   \   \____/   /   ____
                                                                        \   \   \      /                                                    \  /            \  /   /
                                                                         \   \   \____/                                                      \/   ________   \/   /
                                                                          \  /                                                                    \       \      /
                                                                           \/                                                                      \____   \____/
                                                                                /
                                                                                ____/

(It’s a fourth-generation Gosper curve.)
Rules

You may optionally add any amount of trailing spaces to each line.
You may optionally add an equal amount of leading spaces to all lines.
You may prepend or append any amount of lines consisting of zero or more spaces.
You may submit a function or a full program.
The shortest code in bytes wins.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
So sayeth the Shepherd
I'm tired, but I can't seem to fall asleep. Help me count sheep.
Given an input N (positive integer), make N sheep jump over an ascii fence, like the sample below. Only one frame should be displayed at once:
o |-|
──|-|──  0

 o|-|
──|-|──  0

   o
  |-|
──|-|──  0

  |-|o
──|-|──  0

  |-| o
──|-|──  0

o |-|
──|-|──  1

 o|-|
──|-|──  1

   o
  |-|
──|-|──  1

Count should be kept at the lower right side of the 'ground'. Trailing and leading whitespace and newlines are allowed. If your language of choice has difficulty clearing the screen for each frame you can add sufficient newlines to clear the screen - please state how many lines you add for this in your answer. The program should terminate when the N'th sheep is on the fifth floortile.
I need to get up early tomorrow, so shortest code in bytes wins. Please submit a function or complete program. Standard loopholes apply.

Please, it pains me when people use justifications for short code ("I need to get up early tomorrow")  2. How much whitespace do we put between frames? It looks like 1 newline to be, but you may want to state that clearly.

take aspirin 2) There may be only 1 frame on screen. These frames here are to demonstrate each state individually and should NOT be visible on 1 screen simultaneously.

Okay, you might want to specify that the test case is not accurate then.

Many languages do not have the option to clear display, in such cases what output should they provide?

Edited question to clear out the 1 frame / CLS vs newlines issue.

"add sufficient newlines to clear the screen". Isn't that dependent on the size of the output window as well as screen resolution?

@Emigna Yes, that's why I want people to add that to their answer, to see the assumption you make in that area.

Meaning the the most efficient solution is to use 0 or 1 newline and have a window small enough to only fit 1 "frame" at a time.

Can we count ─ as one byte?

@Arnauld Depends on your code page, I guess?.In ASCII it's 1 byte.

According to your example, for N=3 the last frame will contain a sheep at the right end and the counter will still say 2. Is that correct?

@LuisMendo Correct.

May I add a frame with no sheep?

@Titus No, you may not.

related

MATL, 60 56 53 bytes
:"@qXJx[HKCbO]"7Z"'  |-|  'v'o'@('--|-|--  '  JVhXxXD

The animation with the above code runs very fast. The following version includes a pause to make the animation slower and thus easier to see (not required by the challenge), at the cost of 4 more bytes:
:"@qXJx[HKCbO]"7Z"'  |-|  'v'o'@('--|-|--  '  JVhXxXD.2Y.

Try it at MATL Online! The interpreter is a beta; refresh the page if it doesn't work.
Or see a recording from the offline compiler:

Explanation
:"              % Input N implicitly. Repeat N times
  @q            %   Push iteration index minus 1, that is, from 0 to N-1. This
                %   are the numbers of sheep
  XJx           %   Copy into clipboard J and delete
  [HKCbO]       %   Push array [2 4 7 -2 0]
  "             %   For each value in that array. This loops generates the 5
                %   frames for each number of sheep
    7Z"         %     Push string of 7 spaces
    '  |-|  '   %     Push this string
    v           %     Concatenate vertically. This gives a 2x7 char array
                %     with the upper part of the frame, except the 'o',
                %     which will be now placed in a varying position
    'o'         %     Push string 'o'
    @           %     Push loop variable, that is, 2, 4, 7, -2 or 0
    (           %     Write 'o' into that position of the 2x7 char array.
                %     The position is interpreated linearly, that is, a single
                %     number is used as index into the 2D array in column-major
                %     order (down, then across). So index 2 is lower-left corner,
                %     index 4 is to the right of that etc. Indexing is
                %     semi-modular (modular for non-positive values). So 0 is
                %     the lower-right corner, and -2 is to the left of that
    '--|-|--  ' %     Push this string
    JV          %     Push current number of sheep converted to string
    h           %     Concatenate horizontally
    Xx          %     Clear screen
    XD          %     Display all stack contents
    .2Y.        %     Pause for 0.2 seconds (optional)
                %   End implicitly
                % End implicitly

JavaScript (ES6), 120 124 bytes
f=(n,m=`   2
43|-|10
──|-|── `,s=0)=>n?alert(m.replace(s%5,'o').replace(/\d/g,' ')+' '+(n-1),(++s%5?f(n,m,s):f(n-1,m,0))):''

The last frame computed is showing first.
Thanks to this the jump number is n-1
In alert, charaters have different width so it looks like it's broken.

f=(n,m=`   2
43|-|10
──|-|── `,s=0)=>n?alert(m.replace(s%5,'o').replace(/\d/g,' ')+' '+(n-1),(++s%5?f(n,m,s):f(n-1,m,0))):''
;

f(2);//You'll get 10 alert popup

Previous answer:
120 bytes, the jump number is wrong because it starts at 1 instead of 0
f=(n,m=`   2
43|-|10
──|-|── `,s=0)=>n?alert(m.replace(s%5,'o').replace(/\d/g,' ')+' '+n,(++s%5?f(n,m,s):f(n-1,m,0))):''

@LuisMendo I updated the counter to start at 0. For the bars it's thanks to the font used by alert. I have the same result than chrome with edge, and it's worse with firefox.

JavaScript (ES6), 144 142 bytes
Clears the output and waits 300ms between each frame:
n=>(F=j=>((c=console).clear(),c.log(`   2
01|-|34
──|-|── `.replace(/\d/g,i=>(j-i)%5?' ':'o')+(j/5|0)),++j<n*5&&setTimeout(`F(${j})`,300)))(0)

You can test it here (make sure to open the console).

This doesn't seem to increment the counter (from 4 to 5) after the last sheep has jumped the fence...

@ʰᵈˑ - I think this is the expected behavior. (See Luis Mendo's question in the challenge comments.)

Ah yes, I didn't read that - link to comment for anyone else

C#, 234 Bytes
using C=System.Console;class P{static void Main(string[]a){for(int n=0;n-1+""!=a[0];++n){foreach(int p in new[]{5,6,3,10,11}){C.Clear();C.Write("    \n  |-|  \n──|-|── ".Remove(p,1).Insert(p,"o")+n);for(var w=3e7;w>0;--w);}}}}

At a first glance, there's some whitespaces laying around at string[] args and at for (int. Int32.Parse could be int.Parse.

You can change the name of the class from Program to just P or something

string could be var. The integer in the for loop could be initialized at the same time you parse args[0] to an integer.

I see you edit the byte count each time it is lowered. However, I recommend keeping around old byte counts (crossed with a line), to keep track of the progress :)

You only need to have a function so compile to an Action<string[]> and you can remove the brackets around the outer for loop so I believe I get 200 bytes: using C=System.Console;a=>{for(int n=0;n-1+""!=a[0];++n)foreach(int p in new[]{5,6,3,10,11}){C.Clear();C.Write("    \n  |-|  \n──|-|── ".Remove(p,1).Insert(p,"o")+n);for(var w=3e7;w>0;--w);}};

Ruby, 83 bytes
->n{(n*5).times{|i|$><<"   c
  |-|
ab|-|de  #{i/5}
".tr('abcde',' '*(i%5)+'o ')}}

Prints to stdout. Output separated by newlines. Reducing screen height to 3 makes only one image visible at a time.

Tcl, 168 bytes
Version using 10-row-high screen. (Replace the 7 below with your screen height in columns minus four.)
set s {0 1 2 3 4 }
for {set n 0} {$n<$argv} {incr n} {foreach x $s {
puts [string repe \n 6][string map [split $s {}] [string map "$x o" {   2
01|-|34
--|-|--  }]]$n}}

That runs really fast, so you can add a pause on line two:
Tcl, 177 bytes
set s {0 1 2 3 4 }
for {set n 0} {$n<$argv} {incr n} {foreach x $s {after 250
puts [string repe \n 6][string map [split $s {}] [string map "$x o" {   2
01|-|34
--|-|--  }]]$n}}

It works by reusing the string at the top for two different things:

as a list for the inner loop (to display each version of the sheep+fence)
as a mapping of digit→space to remove digits from the sheep+fence image template

The template itself is the string image to display. First we map (string replace) the sheep's current position digit (inner loop) to an 'o'. Then we map the remaining digits to spaces. Then we print the resulting string.
(The string itself starts after the last { on the third line and ends with the leftmost } on the last line.)

QBasic, 110 bytes
INPUT n
FOR i=0TO 5*n-1
CLS
?
?"  |-|"
?"--|-|-- ";i\5
x=i MOD 5
LOCATE(x=2)+2,1+x-(x>1)+x\3
?"o"
SLEEP 1
NEXT

Loops over 5*n ticks. At each tick, clears the screen, prints the stile and sheep count, and then uses LOCATE to print the o at the appropriate spot. With x being the position code between 0 and 4:

Row: (x=2)+2

If x=2 is true, -1+2 = 1
If x=2 is false, 0+2 = 2

Column: 1+x-(x>1)+x\3

If x is 0 or 1, x>1 is false and x\3 is 0: 1+x-0+0 = 1 or 2
If x is 2, x>1 is true and x\3 is 0: 1+x-(-1)+0 = 4
If x is 3 or 4, x>1 is true and x\3 is 1: 1+x-(-1)+1 = 6 or 7

Finally, SLEEP for 1 second and loop. If you don't mind hitting enter at every frame, I can shave two bytes by removing the argument to SLEEP.

node.js + sleep, 169 bytes
c='   2\n01|-|34\n──|-|──  '
for(i=0;i<process.argv[2]*5;require('sleep').sleep(1))console.log('\033[2J'+c.replace(i%5,'o').replace(/\d/g,' ')+Math.floor(i++/5))

Original solution
node.js, 146 142 185 bytes
Tested with ubuntu terminal only (and now with n sheeps):
i=0
c='   2\n01|-|34\n──|-|──  '
setInterval(function(){console.log('\033[2J'+c.replace(i%5,'o').replace(/\d/g,' ')+Math.floor(i++/5))
if(process.argv[2]*5==i)process.exit()},9)

Well, that's a frame every 9 ms. A more sleep-soothing version (frame every 1s):
i=0;setInterval(function(){console.log('\033[2J'+'   2\n01|-|34\n──|-|──  '.replace(i%5,'o').replace(/\d/g,' ')+Math.floor(i++/5))},1000)

And ungolfed:
var i = 0;
setInterval(function(){
  console.log('\033[2J' + '   2\n01|-|34\n──|-|──  '.replace(i%5, 'o').replace(/\d/g, ' ') + Math.floor(i++/5));
}, 1000)

In my first solution, I forgot the parameter for N sheeps

PHP, 132 131 bytes
Edits after comments (thanks!):
<?php for(;$i<$argv[1]*5;sleep(1),system(clear),$c="
  |-|
──|-|──  ".floor($i/5),$c[[5,6,3,10,11][$i++%5]]=o)echo$c;

Which is ungolfed:
<?php

ini_set('error_reporting', '0');        # golfing precondition

for(; $i<$argv[1]*5;                    # repeat N times
  sleep(1),                             # sleep after iteration
  system(clear),                        # clear screen (linux only)
  $c = "
  |-|
──|-|──  " . floor($i / 5),             # define template
  $c[[5, 6, 3, 10, 11][$i++ % 5]] = o)  # replace with sheep (and finish "for" statement)
  echo $c;                              # output result

Original post
<?php $i=0;for(;;){system("clear");$c="  \n  |-|  \n──|-|──  ";$c[[3,4,1,8,9][$i%5]]='o';echo"  $c".floor($i++/5);sleep(1);}

Tested on ubuntu (don't know, if system("clear") works on windows)
Ungolfed:
<?php
$i = 0;
for(;;) {
  system("clear");
  $content = "  \n  |-|  \n──|-|──  ";
  $content[[3,4,1,8,9][$i%5]] = 'o';
  echo "  $content " . floor($i++/5);
  sleep(1);
}

Idk either about Windows, but I´m sure that clear needs no quotes.

Thinking about Windows ... it was cls in DOS.

Remove the $i=0;, warnings are typically not displayed in code golf (-5 bytes). For the same reason, you don't need quotes around clear and o (-4 bytes). Replace the \ns by real newlines (-2 bytes). Since you only have expressions, not any statements, you can put everything but the last one in your for loop, allowing you to remove the brackets (for(;;system(clear),$c=…)sleep(1);) (-2 bytes). And finally, you forget to add the condition $i<$argv[0] (+ 11 bytes).

Thank you! I did not get an echo into the loop. But the reposted solution is doing it.

PHP+JavaScript, 168 bytes
<?extract($_GET);$s="     ";$s[$f=++$f%5]=o;echo strtr("<pre>   C
AB|─|DE
──|─|── $c",EABCD,$s),($c+=!$f)<$n?"<script>location.href='s.php?n=$n&c=$c&f=$f'</script>":"";

Save to file s.php, call in browser with s.php?n=<n>.
Calls itself with new parameters for every frame, no delay.

I could save 5 more with index.php; but I don´t want to go that far.

I've tried running this on PHP 5 and 7, but all Chrome gives me is C AB|─|DE ──|─|── $c",EABCD,$s),($c+=!$f)<$n?".

@steenbergh You have short_open_tag disabled. Enable it (default) or add php+space after <?.

Yup, that's it. Got it running now.

05AB1E, 66 60 59 bytes
FNU5Fð4×N<i¨'oJ},N<iðë'o}ðNÉis}"|-|  "JN1›iR},…──|Â'-sððXJ,

Uses CP-1252 encoding.
Explanantion
Iteration refers to the inner iteration (0 -> 4) of the sheeps journey.
Main loops
F      # For N in range [0 .. input)
 NU    # Save N in variable X
 5F    # For N in range [0 .. 5)

Generate top row
ð4×         # push 4 spaces
N<i    }    # if we're on the 2nd iteration
   ¨'oJ     # replace the last space with an "o"
,           # print row

Generate middle row
N<iðë'o}     # push a space if we're on the 2nd iteration, else push "o"
ð            # push a space
NÉis}        # if we're on an odd numbered iteration, swap the stacks top 2 chars
"|-|  "      # push this string
J            # join the stack to one string
N1›iR}       # if we're on the any of the last 3 iterations, reverse the string
,            # print row

Generate bottom row
…──|  # push the string "──|"
Â     # push a reversed copy
'-s   # push "-" between the 2 strings on the stack
ðð    # push 2 spaces
X     # push the N we saved in the main loop (current sheep number)
J,    # join and print row

Python 2, 171 159 144 bytes, 163 151 136 characters
Solution using a recursive function. Call as f(int)
EDIT
-12 after rereading the comments and seeing that the count does not have to increment when the sheep reaches the end of the field
-15 by iterating through the index list directly and losing a variable
def f(a,x=0):
 if a>0:
  for c in 5,6,3,10,11:
   b=list('    \n  |-|  \n──|-|──  ');b[c]='o';print"\n"*50+"".join(b)+(`x`)
  f(a-1,x+1)

Notes
Assumes UTF-8 encoding
Using - instead of ─ (as in @Luis MATL answer) would bring the byte count down by 8 to match the character count and would lose the UTF-8 dependency
50 newlines added - output is at the bottom on the console (cheaper than importing and using os.system("clear") and works on Windows and Linux)
Version with 1 second time delay between outputs (170 bytes, 162 characters)
import time
def f(a,x=0):
 if a>0:
  for c in 5,6,3,10,11:
   b=list('    \n  |-|  \n──|-|──  ');b[c]='o';print"\n"*50+"".join(b)+(`x`);time.sleep(1)
  f(a-1,x+1)

Bash + standard Linux utilities (339 bytes)
e(){ echo "$@";}
n(){ e -n "$@";}
r(){ [ $? -eq 0 ]&&s=o||s=" ";[ $1 ]&&n " $s "||n "$s";}
f(){ k=$(($1%5));n "  ";[ $k -eq 2 ];r .;e "  ";for i in 0 1;do [ $k -eq $i ];r;done;n "|-|";for i in 3 4;do [ $k -eq $i ];r;done;e;n "──|-|──";}
for l in `seq 1 $1`;do for z in `seq 0 4`;do clear;f $z;e "  $((l-1))";sleep 1;done;done

Jelly, 55 54 53 bytes
ị30214D¤“o    ”ṙ“   “
““|-|““
__|-|__  ”ż
×5Ḷµ:5ż@Ç€Y

TryItOnline
Prints frames separated by line feeds.
How?
ị30214D¤“o    ”ṙ“   “
““|-|““
__|-|__  ”ż           - Link 1, build a frame without counts: frameNumber
       ¤              - nilad and link(s) as a nilad:
 30214                -     literal 30214 (a nilad)
      D               -     to decimal: [3,0,2,1,4]
ị                     - index into (1-based and modular, so frames go 4,3,0,2,1,4,...)
        “o    ”       - string "o    "
               ṙ      - rotated to the left by that number
                “   “ - the rest, except the last character, is:
““|-|““               -     an array of strings ["   ","\n","","|-|","","\n__|-|__  "]
__|-|__  ”            -     i.e. split where a sheep might go

          ż           - zip the sheep (the rotated "o    ") into that

×5Ḷµ:5ż@Ç€Y - Main link: nSheep
×5          - multiply by 5 -> nFrames
  Ḷ         - lowered range: [0,1,2,...nFrames-1]
   µ        - monadic chain separation
    :5      - integer division by 5 (vectorises): [5 zeros, 5 ones, ..., 5 (nSheep-1)s]
      ż@    - zip with reversed arguments
        Ç€  - call last link (1) as a monad for each (zip sheep numbers with frames)
          Y - join with line feeds (TODO: replace with future animate frames atom :p)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Build an aesthetically pleasing divisor tree
An aesthetically pleasing divisor tree is a tree of divisors of input n that, for any composite number m, has two children nodes that are the pair of divisors that are closest to the square root of m. The left node should be the smaller divisor of m and the right node should be the larger divisor of m. A prime number in the tree should have no children nodes. Your tree may be in the form of text art or an image. The rules for text art output are as follows.
Spacing rules
To space out the nodes on the tree, we have the following rules:

The nodes at a given depth from the root should all be on the same line of text in the output.

  /  \    NOT    /  \
 /    \         /    3
2      3       2

For left nodes, the incoming branch should be on the upper right if the node is a single-digit number, else, just above the last digit. Example:

 /    AND    /
3          720

For right nodes, the incoming branch should be on the upper left if the node is a single-digit number, else, just above the first digit. Example:

\    AND    \
 7          243

For outgoing left branches, the branch should begin one space to the left of the number. Example:

  275
 /
11

For outgoing right branches, the branch should begin one space to the right of the number. Example:

275
   \
   25

Any two nodes on the same level of the tree should have a minimum of two spaces between them. At the same time, any two subtrees on the same level of the tree should have as few spaces between them as possible.

This tree doesn't work because the **subtrees** are too close.

        504
       /   \
      /     \
     /       \
    /         \
   21   .     24
  /  \  .    /  \
 /    \ .   /    \
3      7.  4      6
        . / \    / \
        .2   2  2   3

While this tree does have enough space between its branches.

         504
        /   \
       /     \
      /       \
     /         \
    /           \
   21   ...     24
  /  \  ...    /  \
 /    \ ...   /    \
3      7...  4      6
        ... / \    / \
        ...2   2  2   3

If any two subtrees are too close together on a tree, they can be separated by adding another row of branches /\ to the tree above the parents.

   441
  /   \    Last row is not filled in yet and we have already run out of space.
 21   21
/  \ /  \

Add another row of branches

     441
    /   \     Almost, but the 7 and the 3 are too close together.
   /     \    One more row should do it.
  21     21
 /  \   /  \
3    7 3    7

Add another row of branches

      441
     /   \      And we're done.
    /     \
   /       \
  21       21
 /  \     /  \
3    7   3    7

Examples
As a full example, the divisor tree of 24 will look like this:
     24
    /  \
   /    \
  4      6
 / \    / \
2   2  2   3

4 and 6 are the pair of divisors closest to the square root of 24. 4 is on the left, because it's smaller. On the next line, the number 2 to the left of 3, because it's smaller.
The divisor tree for 63 should look like:
  63        and NOT like this        63
 /  \                               /  \
7    9                             3   21
    / \                               /  \
   3   3                             7    3

In the incorrect tree, 3 and 21 are not the pair of divisors closest to the square root of 63, and 3 and 7 are not sorted properly. The branch placement on the 21 is correct, though.
For 42, you should have:
    42      and NOT        42
   /  \                   /  \
  6    7                 21   2
 / \                    /  \
2   3                  3    7

Let's have a look at 720. Note that we need five levels of branches from 720 so that the 24 and 30 subtrees are correctly spaced. Also, note that 24 and 30 have two levels of branches because 4 and 6 have children nodes that need correct spacing and the children nodes of 30 need to be on the same level as the children nodes of 24.
           720
          /   \
         /     \
        /       \
       /         \
      /           \
     24           30
    /  \         /  \
   /    \       /    \
  4      6     5      6
 / \    / \          / \
2   2  2   3        2   3

The challenge

Your task is to build a correctly-spaced aesthetically pleasing divisor tree for input n, where n is a positive integer greater than 1.
Your output may contain leading and trailing spaces and leading and trailing newlines, but must otherwise conform to the spacing rules given above.
Your output is allowed to be: text art, an image (other formats to be added, if needed).
For images, make sure your tree's nodes are well-spaced, and that nodes at the same height in the tree are at the same height in the image.
This is code golf. Least number of bytes (or equivalent) wins.

Credit to Stewie Griffin for thinking of this idea, and many thanks to Peter Taylor, Martin Ender, Mego, and Eᴀsᴛᴇʀʟʏ Iʀᴋ for their help in rewriting the specification. As usual, any suggestions or corrections are much appreciated. Good luck and good golfing!
More test cases:
2

  4
 / \
2   2

    20
   /  \
  4    5
 / \
2   2

  323
 /   \
17   19

                        362880
                       /      \
                      /        \
                     /          \
                    /            \
                   /              \
                  /                \
                 /                  \
                /                    \
               /                      \
              /                        \
            576                        630
           /   \                      /   \
          /     \                    /     \
         /       \                  /       \
        /         \                /         \
       /           \              /           \
      /             \            /             \
     24             24          21             30
    /  \           /  \        /  \           /  \
   /    \         /    \      /    \         /    \
  4      6       4      6    3      7       5      6
 / \    / \     / \    / \                        / \
2   2  2   3   2   2  2   3                      2   3

              1286250
             /       \
            /         \
           /           \
          /             \
         /               \
      1050               1225
     /    \             /    \
    /      \           /      \
   /        \         /        \
  30        35       35        35
 /  \      /  \     /  \      /  \
5    6    5    7   5    7    5    7
    / \
   2   3

Thank you for this challenge. I can now visualize these things without drawing them each time :D

Does the tree need to look like the examples, or can I use the built-in Mathematica function? It looks like this, but with factorization.

@JHM I knew I should have kept the [tag:graphical-output] tag. Yes, you may use that built-in. I'll edit the challenge.

Python 2, 711 651 575 559 554 547 539 540 530 522 bytes
After four months of trying to write this answer, running into a wall, leaving it for a weeks, rinse, repeat, I have finally finished a proper ASCII art answer for this challenge. All that's left is the golfing, and so, golfing suggestions are very welcome. Try it online!
Golfs: -60 bytes from renaming some often used functions and changing how the result is returned. -73 bytes from changing how the subtrees' heights are checked, how the spacing variables are calculated, and how the result is returned. -3 bytes from FlipTack's isdigit() replacement. -16 bytes golfing that isdigit() replacement even further and replacing " " with E. -5 bytes from minor improvements and changing from Python 3 to Python 2. -7 bytes from modifying how the result is returned. -8 bytes from a small change to how A is defined, changing how T is defined, and adding W, using the hypothesis that any subtree with at least one longer branch than its counterpart, is necessarily longer overall than its counterpart, removing Q altogether, and editing how the result is returned. -10 bytes from using A<10 instead of L(S(A))<2 for A and B. -8 bytes from changing the default H to [0] since the code avoids the problem of mutable default arguments by never mutating H, changing how q is defined by using (B>9) instead of 1-(B<10), removing p altogether, and creating F as a replacement for p+q-M.
Bug fixes: Hypothesis was wrong, counterexample in 11**9 = 2357947691. +1 byte
G=range;L=len;E=" "
def t(n,H=[0]):
 A=max(z*(n%z<1)for z in G(1,int(n**.5)+1));B=n/A;Z=str(n);M=L(Z)
 if A<2:return[Z]
 T=max([i for i in G(L(w))if"/"not in w[i]]for w in(t(A),t(B)));V=H[1:]or[T[k+1]-T[k]-1for k in G(L(T)-1)];x=t(A,V);y=t(B,V);P=x[0].rindex(str(A)[-1])+(A<10);q=y[0].index(str(B)[0])+(B>9);F=L(x[0])-P+q-M;h=H[0]or(F+M%2+2)/2or 1;return[E*(P+J)+(J<h and"/"+E*(2*h+M-2*J-2)+"\\"or Z)+E*(L(y[0])-q+J)for J in G(h,-1,-1)]+[(E*(2*h-F)).join(I<L(w)and w[I]or E*L(w[0])for w in(x,y))for I in G(max(L(x),L(y)))]

Explanation
The whole function can be boiled down to about four steps:

Determine the largest divisor pair of n, A and B.
Make the subtrees of A and B, redrawing as needed.
Determine the number of spaces that should go between the subtrees.
Draw and return the new divisor tree.

I will go through each step in order.
Step 1. This is the easiest step, quite frankly. Check every number z between 1 and the square root for divisibility into n and grab the largest z and n//z that matches. Return just str(n) if n is prime (either A==1 or B==n)
Step 2. Draw the subtrees of A and B and get the number of /\ branches between nodes in the subtrees. To do this, we get the indices of every step that has digits in them, get the first differences of the indices,  and subtract 1 again. Once we have the heights, we compare them to get the largest, and redraw the subtrees with the new heights.
I have a sneaking suspicion that the subtree that is taller overall always has branches as long as or equal to the branches on the shorter subtree, and I can use that to golf the code, but I have no proof of this yet. Counterexample in 11**9 = 2357947691.
Step 3. This step is what took months to write. Step 2 took a few days to write and debug, but finding the right formulas for the spacing took ages. I'll see if I can condense what I figured out into a few paragraphs. Note that some of the code in this explanation has since been golfed out of the real code.
First, p, q, h, P, Q, s and M.p is the number of characters from the end of the left branch / to the right end of the left subtree. q is the number of characters from the left end of the right subtree to the end of the right branch /. h is the number of branches between the root and the subtrees. P and Q are just the inverses of p and q and are useful for placing the spaces around /\ branches up to the root n. s is the number of spaces that add between the two subtrees. M is simplest; it's the length of n. Put graphically:
            M
           ---
           720
 |        /   \
 |       /     \
h|      /       \
 |     /         \
 |    /           \
   P    p    s   q   Q
------______---____------
     24           30
    /  \         /  \
   /    \       /    \
  4      6     5      6
 / \    / \          / \
2   2  2   3        2   3

The formula for determining p is this: p = len(x[0]) - x[0].rindex(str(A)[-1]) - (A<10), the length, minus the zero-index of the last character in A, minus a correction for single-digit As.
The formula for determining q is this: q = y[0].index(str(B)[0]) + (B>9), the index of the first character in B, plus a correction for zero-indexing, minus a correction for single-digit Bs (combined into one correction for multiple-digit Bs).
The formula for determining h is this: h = H[0] or (p+q+M%2+2-M)//2 or 1. Either we grab from a predefined H which means we're redrawing the tree, we use (from_the_left + from_the_right + parity_space + 2 - len(root)) // 2), or we use the minimum number of branch levels, 1.
The formula for determining s is this: s = 2*h+M-p-q. We subtract p and q from the number of spaces between the root's branches at their widest 2*h + M.
Step 4. And finally we put it all together. First we make the root, [" "*(P+h)+Z+" "*(Q+h)], then we put in the branches down to the subtrees, [" "*(P+J)+"/"+" "*(2*h+M-2*J-2)+"\\"+" "*(Q+J)for J in G(h)][::-1], and finally we put in our properly spaced subtrees, [(" "*(2*h+M-p-q)).join([(I<L(w)and w[I]or" "*L(w[0]))for w in(x,y)])for I in G(max(L(x),L(y)))].
Et voilà! We have ourselves an aesthetically pleasing divisor tree!
Ungolfing:
def tree(n, H=[0]):
    A = max(z for z in range(1, int(n**.5)+1) if n%z<1)
    B = n/A
    Z = str(n)
    M = len(Z)
    if A < 2:
        return [Z]

    # redraw the tree so that all of the numbers are on the same rows
    x = tree(A)
    y = tree(B)
    for W in [x, y]:
        T = [i for i in range(len(W)) if "/" not in W[i]]
    V = H[1:] or [T[k+1]-T[k]-1 for k in range(len(T)-1)]
    x = tree(A, V)
    y = tree(B, V)

    # get the height of the root from the two trees
    P = x[0].rindex(str(A)[-1]) + (A < 10)
    p = len(x[0]) - P
    q = y[0].index(str(B)[0]) + (B > 9)
    Q = len(y[0]) - q
    h = hs[0] or (p+q+M%2+2-M)/2 or 1

    # and now to put the root down
    R = []
    s = 2*h+M-p-q
    for I in range(max(len(x),len(y))):
        c = I<len(x) and x[I] or " "*len(x[0])
        d = I<len(y) and y[I] or " "*len(y[0])
        R += c + " "*s + d,
    for J in range(h, -1, -1):
        if J<h:
            C = "/" + " "*(2*h+M-2*J-2) + "\\"
        else:
            C = Z
        R += [" "*(P+J) + C + " "*(Q+J)]
    return R

Could your isdigit check be '/'<x[i].strip()[0]<':'?

Mathematica, 96 86 81 79 78 bytes
Thanks @MartinEnder for 2 bytes.
TreeForm[If[PrimeQ@#,#,#0/@(#2[#,#2/#]&[Max@Nearest[Divisors@#,#^.5],#])]&@#]&

The output looks like this:

Explanation
Max@Nearest[Divisors@#,#^.5]

Generate the list of divisors of the input. Find the element nearest to the square root of the input. (Max is for flattening the output)
#2[#,#2/#]&

Find the other divisor by dividing the input by the divisor found above, apply the input as the head of the result.
#0/@

Repeat the process.
If[PrimeQ@#,#, ... ]

If the input is prime, don't do anything.
TreeForm

Format the output.
Edit: A more aesthetically pleasing version (258 bytes)
TreeForm[#/.{a_,_,_}:>a,VertexRenderingFunction->(#2~Text~#&),VertexCoordinateRules->Cases[#,{_,_},Infinity,Heads->True]]&@(If[PrimeQ@#,{##},{##}@@#0@@@({{#,#3-#4{1,√3}/2,#4/2},{#2/#,#3-#4{-1,√3}/2,#4/2}}&[Max@Nearest[Divisors@#,√#],##])]&[#,{0,0},1])&

The output looks like this:

Sqrt@# --> #^.5 (of course then you can't use infix notation for Nearest but then you can use Max@).

It follows the rules, but that tree is far from aesthetically pleasing xD

Beauty is in the eye of the beholder :)

I'm not sure that this is valid. Unlike the examples, the nodes on each row aren't evenly spaced. Additionally, the lines don't connect to the correct digit.

@Mego Well, OP said it was valid.

@R.Kap He said a builtin could be used to generate graphical output. It's still expected that it follows the rest of the specification.

@Mego Yeah, but JHM even attached an image of what the output would look like, which I assume OP looked at and then said it was okay to use the built-in.

@Mego And OP even says in his post that the specification is for "text art output".

@BetaDecay I hope the new version looks better :)

@JHM Wow, that's much nicer :)

Charcoal, 302 bytes
≔⟦⟦Ｎ⁰θ⁰¦⁰⟧⟧θＦθ«≔§ι⁰ζ≔⌈Ｅ…·²Ｘζ·⁵∧¬﹪ζκκη¿η«Ｆ⟦η÷ζη⟧«≔⟦κ⊕§ι¹Ｉκ⁰¦⁰⟧κ⊞ικ⊞θκ»⊞υι»»≔…⁰⌈Ｅθ§ι¹ηＦ⮌η«§≔ηι⊕⌈⟦⁰⌈Ｅυ∧⁼§κ¹ι÷Σ⟦¹§§κ⁵¦⁴‹⁹§§κ⁵¦⁰§§κ⁶¦³‹⁹§§κ⁶¦⁰±Ｌ§κ²⟧²⟧ＦυＦ²§≔κ⁺³λ⁺⁺§ηι∨⊖Ｌ§§κ⁺⁵λ²¦¹§§κ⁺⁵λ⁺³λ»Ｆυ«§≔§ι⁵¦³⁻⁻§ι³§η§ι¹∨⊖Ｌ§§ι⁵¦²¦¹§≔§ι⁶¦³⁻⁺⁺§ι³Ｌ§ι²§η§ι¹‹⁹§§ι⁶¦⁰»Ｆ⊕Ｌη«Ｆθ«Ｆ⁼§κ¹ι«←⸿Ｍ§κ³→Ｆ‹⁵Ｌκ«↙Ｐ↙§ηι↗»§κ²↓Ｆ‹⁵ＬκＰ↘§ηι»»Ｍ⊕§ηι↓

Try it online! Link is to verbose version of code. As the verbose version is very verbose, he's a JavaScript transliteration of the main algorithm:
u = []; // predefined variable, used as list of branches
q = [[+s, 0, s, 0, 0]]; // list of nodes starts with the root.
for (i of q) { // iterate nodes, includes new nodes
    z = i[0]; // get node value
    h = Math.max(...[...Array(Math.floor(z ** 0.5) + 1).keys()].slice(2).filter(
        k => z % k < 1)); // find largest factor not above square root
    if (h) {
        for (k of [h, z / h]) {
            k = [k, i[1] + 1, `${k}`, 0, 0]; // create child node
            i.push(k); // add each child to parent (indices 5 and 6)
            q.push(k); // and to master nodelist
        }
        u.push(i);
    }
}
h = new Array(Math.max(...q.map(i => i[1]))); // list of branch heights
for (i = h.length; i --> 0; ) {
    // find branch height needed to space immediate children apart at this depth
    h[i] = 1 + Math.max(...u.map(k => k[1] == j && // filter on depth
        1 + k[5][3] + (k[5][0] > 9) + k[6][2] + (k[6][0] > 9) - k[2].length
        >> 1)); // current overlap, halved, rounded up
    // calculate the new margins on all the nodes
    for (k of u) {
        k[3] = h[i] + (k[5][2].length - 1 || 1) + k[5][3]; // left
        k[4] = h[i] + (k[6][2].length - 1 || 1) + k[6][4]; // right
    }
}
// calculate the absolute left margin of all the nodes under the root
for (i of u) {
    i[5][3] = i[3] - h[i[1]] - (i[5][2].length - 1 || 1);
    i[6][3] = i[3] + i[2].length + h[i[1]] - (i[6][0] > 9);
}
// print the nodes (sorry, no transliteration available)

C (GCC) + Graphviz, 213 bytes
g(n,c,x,k,l){printf("a%d[label=\"%d\"]",k=c,n);for(x=(int)sqrt(n);x>1;x-=1)n%x||(printf("a%d->a%d a%d->a%d ",k,l,k,c=g(x,l=c+1)+1),c=g(n/x,c),x=0);return c;}main(n){scanf("%d",&n);puts("digraph{");g(n);puts("}");}

Assuming the compiled executable is a.out,
run with ./a.out | dot -Tpng.
Takes the input n from stdin and outpus a PNG image to stdout.


text:
Pen Pineapple Apple Pen!
Your task is to print the following:
I have a pen
I have an apple
Uh! Apple pen!

I have a pen
I have pineapple
Uh! Pineapple pen!

Apple pen...
Pineapple pen...
Uh! Pen Pineapple Apple Pen!

Remember, this is code-golf, so the code with the smallest number of bytes wins.
Leaderboards
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
# Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
# Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:
# [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=95124,OVERRIDE_USER=12537;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

Are trailing newlines allowed?

@daHugLenny Only one.

Aargh! That earworm! Not again!

I suppose you expect the program to take no input? There is not much in the way of rules here. Unless it is supposed to be assumed for this type of challenge

Why did you bring that god-awful song to PPCG ;_;

Bubblegum, 72 bytes
00000000: f354 c848 2c4b 5548 5428 48cd e3f2 8472  .T.H,KUHT(H....r
00000010: f214 120b 0a72 52b9 4233 1415 1c41 2c90  .....rR.B3...A,.
00000020: ac22 175c 1e59 7141 665e 2a42 7500 8c07  .".\.YqAf^*Bu...
00000030: d501 d7ad a7a7 c785 2209 1200 eb48 cd43  ........"....H.C
00000040: d205 510f 1453 0400                      ..Q..S..

Try it online!
The above is the xxd hexdump of the actual code.

JavaScript (ES6), 145 143 bytes
_=>`P325|I have |pple|inea|
Uh! | pen`.split`|`.reduce((s,r,i)=>s.split(i).join(r),`1a5
1an a24A25!

1a5
1p3240!

A25...
0...4Pen P32 A2 Pen!`)

let f =

_=>`P325|I have |pple|inea|
Uh! | pen`.split`|`.reduce((s,r,i)=>s.split(i).join(r),`1a5
1an a24A25!

1a5
1p3240!

A25...
0...4Pen P32 A2 Pen!`)

console.log(f());

///, 117 bytes
/@/I have //#/apple//$/Apple //&/Uh! //%/pen//*/Pine/@a %
@an #
&$%!

@a %
@pine#
&*# %!

$%...
*# %...
&Pen *# $Pen!

Try it online!

Jelly, 94 bytes
“/¢ȷKcḞvßÇwİµɼUṡ]nk]¹¤%Ƭ*|ẊƓẸḢÇ2ẋbịʋ]dṀ⁸)ṇẎ⁶ėDṭD’b⁴ị“I“have“a“p“en“¶“n“A“pple“Uh“!“ine“P“...“

TryItOnline
How?
Manual compression:
I looked for strings that repeated and made a list, there were 15.
I ordered these like so:
“I“have“a“p“en“¶“n“A“pple“Uh“!“ine“P“...“
so as to make the smallest base-16 number from the text (with no leading 0)
here: “ separates; ¶ represents a line feed; and the last entry (index 0) is a space.
I then converted the number to base-250 and wrote it out in the first 250 of the 256 characters in the Jelly code-page:
/¢ȷKcḞvßÇwİµɼUṡ]nk]¹¤%Ƭ*|ẊƓẸḢÇ2ẋbịʋ]dṀ⁸)ṇẎ⁶ėDṭD
The code the inverses the same process:
“(base-250-encoded-number)’
b⁴ị - base 16, index into
“I“have“a“p“en“¶“n“A“pple“Uh“!“ine“P“...“
Note: base-15 would have the same byte-count, one less in the encoded number but one more to decode as literal 15 is 15 whereas literal 16 is ⁴. Maybe a substring list of 16 items could cost less in total.

You should be rewarded, but I dunno how... (comments have been deleted, by the way)

Perl, 139 bytes
With UNIX line terminators (LF = one byte) :
s//0an a1
5A12!

0p4
5P42!

A123P4235Pen P4A1Pen!/;s/4/inea1/g;s/0/I have a pen
I have /g;s/1/pple /g;s/2/pen/g;s/3/...
/g;s/5/Uh! /g;print

You should consider using TIO, like this +1

Batch, 203 bytes
@echo off
set e=echo(
call:l "an a" A
call:l pinea Pinea
%e%Apple pen...
%e%Pineapple pen...
%e%Uh! Pen Pineapple Apple Pen!
exit/b
:l
%e%I have a pen
%e%I have %~1pple
%e%Uh! %2pple pen!
%e%

Batch is so verbose that the set e=echo( saves a whole byte. (Worth it of course for code golf purposes.)


text:
How much will this cost?
Given N items (0 < N <= 50) with prices (which are always integers) P0 ... PN-1 and given amounts of each item A0 ... AN-1, determine how much the total cost will be.
Examples
N: 2
P0: 2
P1: 3
A0: 1
A1: 4
Result: 14
N: 5
P0: 2
P1: 7
P2: 5
P3: 1
P4: 9
A0: 1
A1: 2
A2: 3
A3: 2
A4: 3
Result: 60
Remember, this is code-golf, so the code with the smallest number of bytes wins.
Leaderboards
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:
# Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:
# Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:
# [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=95128,OVERRIDE_USER=12537;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

In other words, "find the dot product of two vectors"?

Will the costs always be integers?

@Dennis Yes. They will.

In case it matters, positive integers?

@xnor No, it can be negative

Actually, 1 byte
*

Try it online!
Okay, this is the shortest dot product built-in I could find. >_>

Jelly, 2 bytes
æ.

Try it online!
A built-in computing the dot product between two input vectors: if, for each 1 ≤ i ≤ n, we buy ai items worth pi each, the formula for the total cost is a1p1 + a2p2 + … +anpn, which is precisely the definition of the dot product.

Mathematica, 1 byte
.

Usage:
{1, 2, 3}.{4, 5, 6}

(* 32 *)

TI-Basic, 12 bytes
Prompt L1,L2
sum(L1L2

Haskell, 17 bytes
(sum.).zipWith(*)

Multiply the lists entrywise, then sum. Shorter than importing (23 bytes)
import Data.Vector
vdot

Python, 36 33 bytes
lambda*x:sum(map(int.__mul__,*x))

Thanks to @xnor for golfing off 3 bytes!
Test it on Ideone.

If you can take input as a list of lists, you can do lambda*M:sum(x*y for x,y in zip(*M)) and  lambda*M:sum(map(int.__mul__,*M)).

How about float.__mul__? Should still be one byte shorter.

@Lynn Thanks, but we didn't need to handle non-integers after all.

MATLAB / Octave, 4 bytes
@dot

This defines an anonymous function.
Try it at Ideone.

R, 8 18 bytes
sum(scan()*scan())

Now takes input from stdin.

Submissions must either be full programs or functions.

C#, 25 bytes
p.Zip(a,(x,y)=>x*y).Sum()

Sample program:
using System.Linq;
using Xunit;
public class Tests {
    [Fact]
    public void Cost() {
        int[] p = new [] { 2, 7, 5, 1, 9 };
        int[] a = new [] { 1, 2, 3, 2, 3 };
        int r = p.Zip(a, (x, y) => x * y).Sum();
        Assert.Equal(60, r);
    }
}

Ruby, 34 23 + 9 = 32 bytes
+9 bytes for -rmatrix flag.
->p,a{Vector[*p].dot a}

See it on eval.in: https://eval.in/653676

indirectly you use N as count of arrays

That's sort of an existential question. If N was never defined, would the arrays still exist? If the arrays didn't exist, would N?

Pyth, 3 bytes
s*V

(s)ums the (V)ectorized (*)product of the two input arrays.

Julia 1.0, 13 bytes
Building up on Donat's solution. Thanks to Chartz Belatedly for pointing out the issue with inputs
x/y=sum(x.*y)

Try it online!

Welcome to Code Golf, and nice first answer! Be sure to check out our Tips for golfing in Julia page for ways you can golf your program. Note that we don't allow assuming the input is in a variable, but you can turn this into a function that's 13 bytes long: https://tio.run/##yyrNyUw0rPifaBttaG1kbRzLlWQbbWJtam0W@78iptK2uDRXo0JPq1Lzf2JMUo1dQVFmXklO3n8A

MATL, 2 bytes
*s

Try it online!
*     % Element-wise product of two implicit inputs
s     % Sum of array, implicitly displayed

Java, 67 bytes
a->{int p=0;for(int i=-1;++i<a[0];)p+=a[i+1]*a[i+a[0]+1];return p;}

Slightly ungolfed:
public static int pay(int...a){
  int p=0;
  for(int i=-1;++i<a[0];){
    p+=a[i+1]*a[i+a[0]+1];
  }
  return p;
}

Perl 6, 13 bytes
{[+] [Z*] $_}

Input is a list of two lists
Example:
say {[+] [Z*] $_}(  ((2,7,5,1,9),(1,2,3,2,3))  );
# 60

Explanation:
{          # bare block lambda with implicit parameter ｢$_｣

  [+]      # reduce using addition operator

    [Z*]   # reduce using zip meta-operator combined with multiplication operator

      $_   # the argument ( list of lists )
}

TI-BASIC, 3 tokens
sum(L₁L₂

Input in L₁ and L₂, output in Ans.
Usage:
{1,2,3→L1
{4,5,6→L2
prgmCOST

Output: 32

05AB1E, 3 bytes
øPO

Try it online!
øPO  # full program
  O  # sum of...
 P   # products of...
     # (implicit) each element in...
     # implicit input...
ø    # with each element from the first sublist paired with the corresponding element from the second sublist
     # implicit output

R, 5 bytes
`%*%`

Try it online!
That's the dot-product built-in in R...

JavaScript, 33 bytes
a=>b=>a.reduce((c,d,e)=>c+d*b[e])

Takes input as ([p[0],...,p[n-1])([a[0],...,a[n-1]]).

C, 58 56 bytes
f(n,p,a,s)int*p,*a;{for(s=0;n;s+=p[--n]*a[n]);return s;}

Input is n: number of elements, p:array 1, a:array 2.
Somewhat un-golfed:
f(n,p,a,s)
    int*p,*a;
{
    for(s=0;n;s+=p[--n]*a[n]);
    return s;
}

Welcome to Code Golf, and nice first answer! Be sure to check out our Tips for golfing in C page for ways you can golf your program

APL (Dyalog Classic), 3 bytes
+.×  ⍝ My code is self-documenting

Try it online!

Vyxal s, 1 byte
*

Try it Online!
Magic.

PHP, 46 Bytes
<?foreach($_GET[a]as$n)$s+=$n[0]*$n[1];echo$s;

48 Bytes
<?=array_sum(array_map(array_product,$_GET[a]));

Zsh, 31 25 bytes
Try It Online. old 31 bytes
for i ($p)((S+=i*a[++j]))

This is the core function. The challenge didn't say anything about setting up variables or output so that's all external.

Julia 1.0, 14 bytes
sum((*).(x,y))

Try it online!

PowerShell, 43 bytes
function d($a,$b){$a|%{$r+=$_*$b[$i++]};$r}

Try it online!
Basically, just calculate the dot product.

PowerShell, 36 bytes
param($p,$q)$p|%{$r+=$_*$q[$i++]}
$r

Try it online!

BQN, 3 bytes
+´×

Try it!
dot product