text:
Count the divisors of a number
Introduction
This is a very simple challenge: simply count the divisors of a number. We've had a similar but more complicated challenge before, but I'm intending this one to be entry-level.
The Challenge
Create a program or function that, given one strictly positive integer N, outputs or returns how many divisors it has, including 1 and N.
Input: One integer > 0. You may assume that the number can be represented in your language's native numeric type.
Output: The number of positive integer divisors it has, including 1 and the number itself.
Submissions will be scored in bytes. You may find this website handy, though you may use any reasonable method for generating your byte count.
This is code-golf, so the lowest score wins!
Edit: It looks like FryAmTheEggman's 5-byte Pyth answer is the winner! Feel free to submit new answers, though; if you can get something shorter, I'll change the accepted answer.
Test Cases
ndiv(1) -> 1
ndiv(2) -> 2
ndiv(12) -> 6
ndiv(30) -> 8
ndiv(60) -> 12
ndiv(97) -> 2
ndiv(100) -> 9

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 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=64944,OVERRIDE_USER=45162;function answersUrl(e){return"http://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"http://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

Pyth, 5
l{yPQ

Uses the subsets operation on the prime factors of the input, then keeps only the unique lists of factors and returns this count.
Test Suite
Explanation
Using 25 as an example, so that the subset list isn't very long
l{yPQ     ## implicit:  Q = eval(input()) so Q == 25
   PQ     ## Prime factors of Q, giving [5, 5]
  y       ## All subsets, giving [[], [5], [5], [5, 5]]
 {        ## Unique-fiy, giving [[], [5], [5, 5]]
l         ## Length, print implicity

Fascinating. Nice approach

C++ C, 43 57 56 46 43 bytes
On Martin Büttner's suggestions :
i,c;f(n){for(i=c=n;i;n%i--&&--c);return c;}

Wait, let's count both of them down instead, for 43: i,c;f(n){for(i=c=n;i;n%i--&&--c);return c;}

@MartinBüttner Wow man wow. Seriously! /\

Beautiful! :~)!

LabVIEW, 4938 Bytes
Well its obviously not suited for code golf but whatever, so for my first post and the lolz here goes.

Welcome to Programming Puzzles and Code Golf! How did you score this, if you don't mind me asking? I couldn't find any precedent on Meta.

i saved it and took the size of it

And it was 4.938 bytes? Not kilobytes, for instance?

for accuracy i took the byte count not the kb count

@bkul I think the confusion is due to the ., which I'm pretty sure is meant as a thousand separator, not a decimal point (as is common in some languages).

@MartinBüttner Ah, thank you. I was confused because the Snippet was parsing it as a decimal.

By the way there was a discussion in Meta about how to score LabVIEW, http://meta.codegolf.stackexchange.com/questions/7502/programming-in-labview-how-to-measure-program-size?cb=1

I am well aware, if you read the answer there you will find that it´s mine and a proposed way to count^^

Haskell, 28 bytes
f n=sum[0^mod n i|i<-[1..n]]

Try it online!
The trick here is to test whether a remainder is 0 using the indicator function 0^.
0^0 = 1
0^_ = 0

This works because any positive power of 0 is 0, whereas 0^0 is combinatorially the empty product of 1.
Compare this to filtering
f n=sum[1|i<-[1..n],mod n i<1]

28 bytes
f n=sum[1|0<-mod n<$>[1..n]]

Try it online!
An alternative method using matching on a constant. The <$> infix map might postdate this challenge.

Python 2, 37 bytes
f=lambda n,i=1:i/n or(n%i<1)+f(n,i+1)

A recursive function. The optional input i in the divisor being tested. The expression (n%i<1) tests divisibility, with True (which equals 1) for divisors. The result is added to the recusive expression for i+1. When i==n is reached, the integer floor-division i/n evaluates to 1, and that value is returned as the base case, accounting for n itself being a divisor of n.

38:
lambda n:sum(n%-~i<1for i in range(n))

An anonymous function. Tests all possible divisors 1 through n. This is shifted up from 0 through n-1 in range(n) using -~, which adds 1. Summing the bools uses the fact that Python treats True/False as 1/0.

Dyalog APL, 7 6 bytes
≢∘∪⊢∨⍳

It is an unnamed function that can be named and then reused for each (¨) test case as follows:
      f ← ≢∘∪⊢∨⍳
      f¨ 1 2 12 30 60 97 100
1 2 6 8 12 2 9

Explanation:
 ┌─┴──┐
 ∪  ┌─┼─┐
 ∘  │ ∨ │
 ̸≡  ⊢   ⍳

Count ≢ the ∘ unique ∪ of the GCD ∨ of itself ⊢ and each of the integers-until ⍳.
Thanks to ngn for saving a byte.

Old version: +/0=⍳|⊢
This is how it works:
  ┌─┴─┐
  / ┌─┼───┐
┌─┘ 0 = ┌─┼─┐
+       ⍳ | ⊢

⍳|⊢ 1-through-argument division-remainder argument
0= Boolean if 0 is equal to the division rest
+/ Sum of the boolean, i.e. count of ones.

Golfscript, 19 18 17 13 bytes
With thanks to Martin Büttner.
~.,\{\)%!}+,,

How it works
~               Evaluate the input, n
 .,             Duplicate the input, create array [0..n-1]
   \            Swap array and n
    {    }+     Add n to block == {n block}
     \          Swap n with i in array
      )         Increment i
       %        n mod i
        !       Logical not so that 1 if divisible by n else 0
           ,    Filter array using block for all i divisible by n
            ,   Get length of the filtered array, the answer

Also
From @Peter Taylor, also in 13 bytes.
~:X,{)X\%!},,

How it works
~               Evaluate the input
 :X             Store input in variable X
   ,            Create array [0..X-1]
    {     },    Filter array using the following block
     )          Increment i in array
      X\        Add X to stack, swap with i
        %       X mod i,
         !      Logical not so that 1 if divisible by n else 0
            ,   Get length of the filtered array, the answer

For the same length you could also have ~:X,{)X\%!},,

Retina, 17 bytes
(?<=(.+))(?=\1*$)

Input in unary, output in decimal.
Try it online.
When invoked with a single regex, Retina simply counts the matches. The regex itself matches a position, where the unary number to the left of it is a divisor of the entire input. I'm also making use of the fact that lookarounds are atomic, so that I don't need to use a ^ anchor.
The first lookbehinds simply captures the entire prefix in group 1. This can never fail, so after the lookbehind we know that's what's in group 1 and it won't change any more.
The lookahead then checks if we can reach the end of the string by repeating the captured string (our potential divisor) 0 or more times.

J, 10 bytes
[:*/1+_&q:

This is an unnamed, monadic verb. It calculates σ0(∏pkαk) as ∏(αk + 1).
Try it online with J.js.
How it works
[:*/1+_&q:    Right argument: y

      _&q:    Compute all exponents of the prime factorization of y.
    1+        Add 1 to each exponent.
[:*/          Reduce by mutiplication.

I don't think q: is allowed as it solves an essential part of the challenge. How about just [:+/0=]|~1+i.

That would be a duplicate of this answer. Also, built-ins are not forbidden by default, and the challenge doesn't seem to mention them.

Builtins that do all / almost all of the work of a challenge are usually forbidden but I can follow your reasoning for q: .

They are not. I wish they were, but they are not.

Hrmpf hrmpf that sucks a little.

Julia, 20 bytes
n->sum(i->n%i<1,1:n)

This is an anonymous function that works as follows: For each integer from 1 to the input, test whether the input modulo the integer is zero. If so, the value will be true, otherwise false. We sum over the booleans which are implicitly cast to integers, yielding the number of divisors.

A much cooler (though also much longer) solution, included for the sake of completeness, is
n->prod(collect(values(factor(n))).+1)

This gets the canonical factorization of n, i.e. \prod_{i=1}^k p_i^e_i, and computes the divisor function as τ(n) = \prod_{i=1}^k e_i + 1.

J, 13 12 11 bytes
My first golf in J. I'm still learning it.
Saved a byte thanks to Dennis.
Saved one more byte thanks to randomra.
1+/@,0=i.|]

Explanation:
1+/@,0=i.|]
       i.        the array 0 .. n-1
         |]      mod n
     0=          replace 0 by 1, and nonzero entries by 0
1   ,            prepend 1 to the array
 +/@             take the sum

Arcyóu, 12 bytes
Let's get the party started!
(F(x)(_(d/ x

This uses the built-in function d/. Here's a version without the built-in (27 bytes):
(F(x)(](+(f i(_ 1 x)(‰ x i

Explanation:
(F(x)              ; Anonymous function with one parameter x
  (]               ; Increment
    (+             ; Sum
      (f i(_ 1 x)  ; For i in range from 1 to x-1 inclusive:
        (‰ x i     ; x divisible by i

CJam, 11 bytes
ri_,:)f%0e=

Test it here.
Explanation
CJam doesn't have a built-in for this, so we're doing trial division.
ri  e# Read input and convert to integer N.
_,  e# Duplicate and turn into range [0 1 ... N-1]
:)  e# Increment each element in the range to get [1 2 ... N]
f%  e# Take N modulo each of the list elements.
0e= e# Count the zeroes.

Bonus
Here is an interesting solution at 12 bytes (which I suspect might be shortest in a language like J):
ri_)2m*::*e=

The result is equal to the number of times n appears in an n x n multiplication table:
ri  e# Read input and convert to integer N.
_)  e# Duplicate and increment.
2m* e# Take Cartesian product of [0 1 ... N] with itself.
::* e# Compute the product of each pair.
e=  e# Count the occurrences of N.

Matlab, 20 bytes
Perform k mod n for every k = 1,...,n, then perform not (which turns every nonzer to zero and every zero to 1) and sum up all those values.
@(n)sum(~mod(n,1:n))

This would have been my approach too!

Interesting that this is the same length as length(divisors(n)).

@Acccumulation you'd still need to add a @(n) to make it a valid submisison

Jelly, 2 bytes
Æd

Try it online!
I think this uses features implemented after the other Jelly answer. Comment if I'm wrong though (I can't look each commit in the row, you know :))

Excel Formula, 42 28 bytes
Edit: I just realised I do not need to use INDIRECT, saving 14 bytes!
The following should be entered as an array formula (Ctrl+Shift+Enter):
=SUM(--NOT(MOD(N,ROW(1:N))))

Where N is the number to test.
Examples:
{SUM(--NOT(MOD(32,ROW(1:32))))}
Result: 6
{SUM(--NOT(MOD(144,ROW(1:144))))}
Result: 15

Explanation:
SUM(--NOT(MOD(N,ROW(1:N))))       Full formula

                ROW(1:N)          Generates an array of row numbers e.g {1;2;3;4;...N}
          MOD(N,ROW(1:N))         Does N MOD {1;2;3;4;,...N}
      NOT(MOD(N,ROW(1:N)))        Coerces zeros to ones, so that they may be counted, but actually returns an array of TRUE;FALSE;FALSE;...
    --NOT(MOD(N,ROW(1:N)))        Coerces the TRUEs to 1s and FALSEs to 0s.
SUM(--NOT(MOD(N,ROW(1:N))))       Sum the ones for the result.

05AB1E, 2 bytes
Ñg

Try it online or verify all test cases.
Explanation:
Pretty straight-forward, but here it is anyway:
Ñ   # Push a list of divisors of the (implicit) input-integer
    #  i.e. 100 → [1,2,4,5,10,20,25,50,100]
 g  # Pop and push the length of this list
    #  i.e. [1,2,4,5,10,20,25,50,100] → 9
    # (which is output implicitly as result)

Perl 6, 17 bytes
{[+] $_ X%%1..$_} # 17

usage:
say {[+] $_ X%%1..$_}(60); # 12␤

my $code = {[+] $_ X%%1..$_};

say $code(97); # 2␤

my &code = $code;
say code 92; # 6

Pyth, 8 bytes
Simple trial division.
lf!%QTSQ

Try it online here.

PARI/GP, 6 bytes
PARI/GP have a built-in for this.
numdiv

i'm not sure, but I think that according to meta, for builtins, you can't merely restate it.

@Maltysen I think it's allowed. http://meta.codegolf.stackexchange.com/a/7206/9288

Octave, 21 20 bytes
@(n)nnz(~mod(n,1:n))

I like the nnz, great usage here=)

Ruby, 27 bytes
->n{(1..n).count{|i|n%i<1}}

Sample run:
2.1.5 :001 > ->n{(1..n).count{|i|n%i<1}}[100]
 => 9

Regex (.NET), 33 bytes
^((?=.*$(?<=^\2*(.+?(?>\2?)))).)+

Assuming input and output are in unary, and the output is taken from the main match of the regex.
Break down of the regex:

.*$ ets the pointer to the end of the string so that we have the whole input x in one direction.
(?<=^\2*(.+?(?>\2?))) matches from right to left and checks for divisor by looping from x to 0.

(.+?(?>\2?)) is a "variable" which starts from 1 in the first iteration and continues from the number in previous iteration and loops up to x.
^\2* checks whether x is a multiple of "variable".

It basically has the same idea as my answer to Calculate Phi (not Pi). Only the check is different.
Test the regex at RegexStorm.

Javascript (ES6), 60 57 42 40 39 37 bytes
This can probably be golfed better.
n=>{for(d=i=n;i;n%i--&&d--);return d}

Edit 1: I was right. Removed the braces after the for loop.
Edit 2: Golfed to 40 bytes with thanks to manatwork and Martin Büttner.
Edit 3: Saving a byte by basing the function on the C answer above.
Edit 4: Thanks to ןnɟuɐɯɹɐןoɯ and Neil, but I can't get the eval to work.
Edit 5: Forgot to remove the eval.
Test

n = <input type="number" oninput='result.innerHTML=(

n=>{for(d=i=n;i;n%i--&&d--);return d}

)(+this.value)' />

Give up the good habits. Remove var keywords. More tips in Tips for golfing in JavaScript and Tips for Golfing in ECMAScript 6.

Also give up the bad habits: when you've got a choice between ++i and i++, choose the former (this has nothing to do with golfing). Also n%i<1 should save a byte.

Only briefly tested: n=>{for(d=i=0;i<n;)n%++i<1&&d++;return d}

38: n=>eval('for(d=0,i=n;i;d+=n%i--<1);d')

@manatwork Why not n%++i||++d?

Using @MartinBüttner's C suggestion saves another 2 bytes: n=>{for(d=i=n;i;n%i--&&d--);return d}

@Neil, I was distracted by other tasks when I wrote it. Realized the clumsiness just later when I saw Sahil Arora's C solution.

Use eval to save bytes

Labyrinth, 33 bytes
?:}
  :{:}%{{
@ }   " )
!{("{;"}}

Try it online.
This implements trial division. I'll add a full explanation later. It's probably not optimal, but I'm having a hard time coming up with something shorter.

Jelly, 3 bytes
ÆDL

Uses the builtin for divisors.

PowerShell, 34 bytes
param($x)(1..$x|?{!($x%$_)}).Count

e.g.

PS C:\temp> .\divisors-of-x.ps1 97
2

create a list of numbers from 1 to x, feed them into the pipeline |
filter the pipeline on (x % item == 0), by implicitly casting the modulo result as a boolean and then inverting it using ! so divisors become $true and are allowed through; using the builtin alias ? for Where-Object
gather up () and .Count how many items got through the filter

Very nicely hacked!

Taxi, 2143 bytes
Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:s 1 l 1 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 1 l 2 r.Pickup a passenger going to Cyclone.Pickup a passenger going to Sunny Skies Park.Go to Sunny Skies Park:n 1 r.Go to Cyclone:n 1 l.Pickup a passenger going to Firemouth Grill.Pickup a passenger going to Joyless Park.Go to Firemouth Grill:s 1 l 2 l 1 r.Go to Joyless Park:e 1 l 3 r.[i][Check next value n-i]Go to Zoom Zoom:w 1 r 2 l 2 r.Go to Sunny Skies Park:w 2 l.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l.Pickup a passenger going to Divide and Conquer.Pickup a passenger going to Sunny Skies Park.Go to Joyless Park:n 2 r 2 r 2 l.Pickup a passenger going to Cyclone.Go to Sunny Skies Park:w 1 r 2 l 2 l 1 l.Go to Cyclone:n 1 l.Pickup a passenger going to Joyless Park.Pickup a passenger going to Divide and Conquer.Go to Divide and Conquer:n 2 r 2 r 1 r.Pickup a passenger going to Cyclone.Go to Cyclone:e 1 l 1 l 2 l.Pickup a passenger going to Trunkers.Pickup a passenger going to Equal's Corner.Go to Trunkers:s 1 l.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:w 1 l.Switch to plan "F" if no one is waiting.Pickup a passenger going to Knots Landing.Go to Firemouth Grill:n 3 r 1 l 1 r.Pickup a passenger going to The Underground.Go to The Underground:e 1 l.Pickup a passenger going to Firemouth Grill.Go to Knots Landing:n 2 r.Go to Firemouth Grill:w 1 l 2 r.Go to Joyless Park:e 1 l 3 r.Switch to plan "N".[F][Value not a divisor]Go to Joyless Park:n 3 r 1 r 2 l 4 r.[N]Pickup a passenger going to The Underground.Go to The Underground:w 1 l.Switch to plan "E" if no one is waiting.Pickup a passenger going to Joyless Park.Go to Joyless Park:n 1 r.Switch to plan "i".[E]Go to Sunny Skies Park:n 3 l 2 l 1 l.Pickup a passenger going to What's The Difference.Go to Firemouth Grill:s 1 l 1 l 1 r.Pickup a passenger going to What's The Difference.Go to What's The Difference:w 1 l 1 r 2 r 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:e 3 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 l 1 r.

Try it online!
Ungolfed:
Go to Post Office: west 1st left 1st right 1st left.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: south 1st left 1st right.
Pickup a passenger going to Cyclone.
Go to Cyclone: north 1st left 1st left 2nd right.
Pickup a passenger going to Cyclone.
Pickup a passenger going to Sunny Skies Park.
Go to Sunny Skies Park: north 1st right.
Go to Cyclone: north 1st left.
Pickup a passenger going to Firemouth Grill.
Pickup a passenger going to Joyless Park.
Go to Firemouth Grill: south 1st left 2nd left 1st right.
Go to Joyless Park: east 1st left 3rd right.
[i]
[Check next value n-i]
Go to Zoom Zoom: west 1st right 2nd left 2nd right.
Go to Sunny Skies Park: west 2nd left.
Pickup a passenger going to Cyclone.
Go to Cyclone: north 1st left.
Pickup a passenger going to Divide and Conquer.
Pickup a passenger going to Sunny Skies Park.
Go to Joyless Park: north 2nd right 2nd right 2nd left.
Pickup a passenger going to Cyclone.
Go to Sunny Skies Park: west 1st right 2nd left 2nd left 1st left.
Go to Cyclone: north 1st left.
Pickup a passenger going to Joyless Park.
Pickup a passenger going to Divide and Conquer.
Go to Divide and Conquer: north 2nd right 2nd right 1st right.
Pickup a passenger going to Cyclone.
Go to Cyclone: east 1st left 1st left 2nd left.
Pickup a passenger going to Trunkers.
Pickup a passenger going to Equal's Corner.
Go to Trunkers: south 1st left.
Pickup a passenger going to Equal's Corner.
Go to Equal's Corner: west 1st left.
Switch to plan "F" if no one is waiting.
Pickup a passenger going to Knots Landing.
Go to Firemouth Grill: north 3rd right 1st left 1st right.
Pickup a passenger going to The Underground.
Go to The Underground: east 1st left.
Pickup a passenger going to Firemouth Grill.
Go to Knots Landing: north 2nd right.
Go to Firemouth Grill: west 1st left 2nd right.
Go to Joyless Park: east 1st left 3rd right.
Switch to plan "N".
[F]
[Value not a divisor]
Go to Joyless Park: north 3rd right 1st right 2nd left 4th right.
[N]
Pickup a passenger going to The Underground.
Go to The Underground: west 1st left.
Switch to plan "E" if no one is waiting.
Pickup a passenger going to Joyless Park.
Go to Joyless Park: north 1st right.
Switch to plan "i".
[E]
Go to Sunny Skies Park: north 3rd left 2nd left 1st left.
Pickup a passenger going to What's The Difference.
Go to Firemouth Grill: south 1st left 1st left 1st right.
Pickup a passenger going to What's The Difference.
Go to What's The Difference: west 1st left 1st right 2nd right 1st left.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: east 3rd right.
Pickup a passenger going to Post Office.
Go to Post Office: north 1st left 1st right.

Explanation:
Convert stdin to a number and store it in three locations for three purposes:
   Original (Sunny Skies Park)
   Counter for tested values (Joyless Park)
   Counter for divisors found (Firemouth Grill)
Divide the original by each Joyless Park value in turn.
If the division result equals the truncated division result, then it's a divisor.
When a divisor is found, subtract one from Firemouth Grill.
Repeat until Joyless Park hits zero.
Pickup the original from Sunny Skies Park and subtract the value from Firemouth Grill.
Convert the result to a string and print to stdout.

TI-BASIC, 14 bytes
sum(not(fPart(Ans/cumSum(binomcdf(Ans-1,0

Input is in Ans.
Output is in Ans and is implicitly printed.
This submission will only work for \$1<N<1000\$ due to limitations in the TI calculators.
Examples:
25
              25
prgmCDGF14
               3
100
             100
prgmCDGF14
               9

Explanation:
sum(not(fPart(Ans/cumSum(binomcdf(Ans-1,0   ;full program

                         binomcdf(Ans-1,0   ;generate a list of 1s whose length is the input
                  cumSum(                   ;calculate the cumulative sum
              Ans/                          ;divide the input by each term
        fPart(                              ;get the fractional part of each element
    not(                                    ;logically negate each term
                                            ; 0 becomes 1
                                            ; everything else becomes 0
sum(                                        ;sum the list
                                            ;implicit print of "Ans"

If the above submission does not suffice, then the following 24 byte submission also works for \$0<N<10^{100}\$
Ans→N:0:For(I,1,N:Ans+not(fPart(N/I:End:Ans

Examples:
25
              25
prgmCDGF14
               3
100
             100
prgmCDGF14
               9

Explanation:
Ans→N:0:For(I,1,N:Ans+not(fPart(N/I:End:Ans   ;full program

Ans→N                                         ;store the input in "N"
      0                                       ;leave 0 in "Ans"
        For(I,1,N                   End       ;loop over all integers in [1,N]
                  Ans+not(fPart(N/I           ;increment "Ans" if the current "I"
                                              ; is a factor of "N"
                                        Ans   ;leave "Ans" as the last expression
                                              ;implicit print of "Ans"

Note:  TI-BASIC is a tokenized language.  Character count does not equal byte count.

Japt, 3 bytes
â l

-m flag is for running all the test cases.
Try it

krrp, 22 bytes
^n:,^k:&k+=%nk0@-k1.n.

Try it online!

Explanation
^n:       ~ an anonymous function of arity one
 ,^k:     ~  apply the following function (*) of arity one
  &k      ~   if `k` is zero, return zero; else
   +      ~    add
    =%nk0 ~     boolean (if `k` is a divisor of `n`)
    @-k1. ~     to the current function (*) itself applied to `k-1`
 n.       ~  to `n`

Try it online!

cQuents, 3 bytes
Lz$

Try it online!
Explanation
:Lz$
:       (implicit) given input n, output nth term in sequence
          each term in sequence equals:
 L                                      length (                    )
  z                                              divisors (       )
   $                                                        index

Brachylog, 2 bytes
fl

Try it online!
Takes input through its input variable and outputs through its output variable.
f     The list of factors of
      the input variable
 l    has length equal to
      the output variable.

This exact same predicate, taking input through its output variable and outputting through its input variable, solves this challenge instead.

JavaScript, 3230 bytes
n=(x,y=x)=>y?n(x,y-1)+!(x%y):1

Ungolf:
n=(x,y=x)=>                     //function declaration with y=x preset
           y?                   //check if y=0
             n(x,y+1)           //next divisor(current-1)
                     +!(x%y)    //1 if y is a divisor of x, 0 if not. Or, if x mod y=0.
                            :0  //if y=1, then 0(base case)

32B->30B, -2B for reversing the loop, reducing the condition x-y to y.

x86-16 machine code, 15 bytes
 8B C8          MOV  CX, AX                 ; store input as counter
            DEC_LOOP:
 50             PUSH AX                     ; save input number
 88 0E 0108     MOV  BYTE PTR[AAM1+1], CL   ; modify AAM code operand's second byte
            AAM1:
 D4 0A          AAM                         ; ZF = ( AL % CL == 0 )
 75 01          JNZ  END_LOOP               ; if remainder not 0, continue loop
 43             INC  BX                     ; otherwise increment BX
            END_LOOP:
 58             POP  AX                     ; restore input number
 E2 F3          LOOP DEC_LOOP

Input is AX, output is BX.
This uses (abuses) the arbitrary base ability of the AAM instruction to check if each factor is divisible.  It self-modifies the second byte of the opcode of the AAM with the divisor on each iteration of the loop.

Desmos, 30 bytes
\sum_{n=1}^m(1-sign(mod(m,n)))

Alternatively:
m-sign(mod(m,[1,...,m])).total

View them online

You can save a few bytes in your first answer by replacing 1-sign(...) with 0^{...}: \sum_{n=1}^m0^{mod(m,n)}

Stax, 3 bytes
:d%

Run and debug it
It's the same size when packed.

Burlesque, 6 bytes
rifcL[

Try it online!
Explanation:
ri     # Read integer from input string
  fc   # Get list of factors
    L[ # Get length and implicitly output

Neim, 1 byte
   # Count Divisors

Try it online!
I posted this on a duplicate which got closed, so I figured I'd post it here.

Rockstar, 90 bytes
listen to N
X's0
D's0
while N-X
let X be+1
let M be N/X
turn up M
let D be+M is N/X

say D

Try it here (Code will need to be pasted in)

Add++, 32 29 bytes
+?
Fx,`r,x%i,=0,Ir,,`y,,+1
Oy

Try it online!
Explained (old)
x:?             # Set x to the input
Fx,             # For i in range(x):
    `r,         #       Set the active variable r AND
    x%i,        #       Assign to it the result of x%i
    r=0,        #       And then the result of r==0
    Ir,,        #       If r == 1:
        `y,,    #           Set the active variable to y AND
        y+1     #           Assign to it y + 1
Oy              # Output variable y

29 bytes. Taking advantage of the fact you can omit variables when they’re active, and +? works for taking integer input rather than x:?

TI-BASIC, 10 bytes
sum(not(fPart(Ans/randIntNoRep(1,Ans

This won't work for numbers >999, since that's the maximum size of a list.

I'm honestly somewhat surprised that TI-BASIC doesn't have a builtin for divisors.

This looks familiar...

Mathematica, 16 bytes
Length@*Divisors

Simple function composition of built-ins.

Minkolang 0.13, 16 bytes
ndd[0ci1+%,-]-N.

Check all cases here.
Explanation
ndd           Takes number from input and duplicates it twice (n)
[             Opens for loop that runs n times
 0c           Copies bottom of stack to top (n)
   i1+        Loop counter + 1 (d)
      %       Modulo - pops d,n, then pushes n%d
       ,      Not - 1 if equal to 0, 0 otherwise
        -     Subtract
         ]    Close for loop
-             Subtract (n - 1 for each non-divisor)
N.            Output as number and stop.

Seriously, 17 bytes
,;n;;╟@RZ`i@%Y`MΣ

Try it online with explanation
If my prime factorization function had been working before this challenge, I could get 9 bytes:
,w`iXu`Mπ

PHP, 61 bytes
<?$x=$_GET['x'];for($i=1;$i<=$x;$i++)$c+=$x%$i==0?1:0;echo$c;

I don't know if there's a shorter way to get input in PHP, so I use $_GET.

There´s no shorter input, only $argv[1] which has the same length; but here are some tips to golf this down to 42 bytes

O, 21 bytes
0[Q{Qn)%}d]{n{}{)}?}d

Sample run:
bash-4.3$ ./o o.o <<< 100
9

This is a placeholder until @phase posts the proper O solution.

JavaScript (ES6), 29 bytes
f=(n,i=n)=>i&&f(n,i-1)+!(n%i)

Recursive solution.

MY (noncompeting), 4 bytes
Hex:
1A 3A 47 27

Explanation:
1A - Input from STDIN
3A - List of factors
47 - Length
27 - Output (with newline)

Forth (gforth), 41 bytes
: f 0 over 1+ 1 do over i mod 0= - loop ;

Try it online!
Code Explanation
: f            \ start a new word definition
  0 over 1+ 1  \ set up loop parameters and a value to store the count in
  do           \ loop from 1 to n
    over       \ get n and put it on top of the stack
    i mod 0=   \ check if the current loop index is a divisor of n
    -          \ if so, subtract it from the counter (-1 = true in forth)
  loop         \ end the loop
;              \ end the word definition

C# (Visual C# Interactive Compiler), 42 bytes
n=>Enumerable.Range(1,n).Count(x=>n%x==0);

Try it online!

Suggest n%x<1 instead of n%x==0

Perl 5, 21 bytes
$_-=grep"@F"%$_,1..$_

Try it online!

Knight, 31 bytes
O;=x+=z=y 0P;W>x y=z+z!%x=y+yTz

Try it online!
; go brrrrr
This is a good example of how ordering and chaining can save bytes in Knight (in a manner similar to recursion).
; evaluates two statements and returns the second result which is useful when you have case conflicts.
OUTPUT
   # Chain all but the last z
   # x = prompt(), z = y = 0
   ; (=x + (=z=y 0) PROMPT)
   # Loop for each y up to x
   ; WHILE > x y
       # If x % ++y == 0, increment z
       = z + z (! % x (= y + y 1))
   # The actual statement outputted at the end
   : z

Vyxal, 2 bytes
KL

Try it Online!

Candy, 11 bytes
With the value to test already pushed onto the stack:
~xR(XW%nh)Z
This translates into long form:
peekA   # copy argument from stack into register A
XGetsA  # X := A
range1  # pop argument from stack, push arg, arg - 1, arg - 2, ... 1
while   # while stack not empty
  pushX
  swap    # swap two top stack entries
  mod     # iterated value mod X
  not     # modulo == 0 ?
  popAddZ # Z := Z + popped
endwhile
pushZ     # push Z onto stack, on termination a single value popped and printed

Ceylon, 54 47
Integer d(Integer n)=>(1..n).count((i)=>n%i<1);

This defines a function d which is almost straightforward: Take the list of integers from 1 to n (both inclusive), and apply to each the anonymous function (i) => n%i < 1 (which is a shorter way of writing (i) => i.divides(n)), and count how often it returns true.
Formatted it could look like this:
Integer d(Integer n) =>
        (1..n).count((i) => n%i < 1);

Here we have two versions of 54 bytes each:
Integer d(Integer c)=>{for(i in 1..n)if(n%i<1)i}.size;
Integer d(Integer c)=>sum{1,for(i in 2..n)if(n%i<1)1};
Both use an Iterable comprehension composed of a for and an if clause, with one using .size and the other one using sum, but with an additional literal first entry to convince the compiler it is not empty.

PowerShell, 40 bytes
filter d($n){(1..$n|?{!($n%$_)}).Count}

or
filter d($n){1..$n|%{$s+=+!($n%$_)};$s}

Both versions have the same length. Can't seem to get it shorter.

R, 13 bytes
Assuming that the input is stored in the variable named N.
sum(N%%1:N==0)

Generates a vector of integers from 1 to N, takes N mod each of them, and counts how many of them are 0.

O, 20 18 15 bytes
[H,;]{Qn%0=}d]+

[            ]+ Find the sum of
 H,;]            a list of numbers from the input to 1
     {Qn%0=}d    where we find the mod of the input and each number in the list

Pyth, 15 bytes
Number of divisors, using the prime factorization built-in P, and to avoid an error with 0 < input < 2, where P1 == [] and would break the lambda, it returns 1, since there's only one divisor in that case. Special thanks to @orlp
Try it online here.
JrPQ8?J*FmhhdJ1

MATLAB, 19 21 bytes
Assume, n is defined as the number
sum(mod(n,1:n)==0)

If the function style is required
function t(n)
sum(mod(n,1:n)==0)

Edit: As explained in the comments fixed as an anonymous function and further golfed:
@(n)sum(mod(n,1:n)<1)

You can save one byte by doing: sum(mod(n,1:n)<1)

Jonas, you can make it an anonymous function by simply adding an @(n) in front of it. You can then call the function: ans(12). (i.e. you don't need function.)

Groovy, 34 bytes
f={n->(1..n).findAll{n%it<1}.size}

Provides function f that finds all divisors of n and returns the size.

Hassium, 53 Bytes
func d(i){c=0 for(n=1;n<=i;n++)i%n==0?c++:""print(c)}

See expanded and run online with test case here

C#, 53 bytes
I=>{int s=0,i=1;for(;i<=I;)if(I%i++<1)s++;return s;};

Recursive solution, 72 bytes:
I=>{return y(I,1);};y=(J,C)=>{return C==J?1:J%C<1?1+y(J,C++):y(J,C++);};

Okay, recursion was not the answer here since I needed a helper function.

Axiom 27 bytes
f(x)==(x=1=>1;#divisors(x))

results
(21) -> for i in [1,2,12,30,60,97,100] repeat output [i,f(i)]
   [1,1]
   [2,2]
   [12,6]
   [30,8]
   [60,12]
   [97,2]
   [100,9]

Befunge-93, 110 104 bytes
10:p010p&v>10g   >.@       |%g:0:<
`*:g:0:  <p:0+1g:0<p01+2g01<     |
0:g:*-   #v_10g1+v^        <     >

Try it online!

Scala, 59 61 57 bytes
n=>1.to(n).map(i=>println(i,1.to(n).filter(i%_==0).size))

This seems to print out the results for all the numbers from 1 to 100.  Shouldn't it take input and calculate on the input?

@WheatWizard you are correct, I was mixing it up with https://code-golf.io/divisors#python, fixed.

It would also help to have a link to an online interpreter, like Try It Online. I'd edit one in myself, but don't know Scala, so haven't managed to actually invoke the lambda.

@UnrelatedString Thanks I'll make sure to include this in the future

Your earlier answer doesn't seem to be working, but this should (27 bytes).

Thunno 2 L, 1 byte
F

Attempt This Online!
Or 2 bytes flagless:
Fl

Attempt This Online!
F gets the list of all factors, and l gets the length.

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


text:
Golf yourself a beer
It's friday! Which means it's time for beer!
Sadly though, today we will be golfing beer instead of drinking it. :(
Challenge
Output a beer and drink it. The amount of sips you take changes your output.
Sips
Your program should take one input string. This string can solely consist out of concatenated sips.
If the input is an empty string, you should output a full beer glass, including foam.
The more sips you take, the emptier your beer glass will be.
If you take 0 sips, your beer still has foam. The output of this foam is always the same (see examples).
If you take 1 sip, you should output the beer glass, followed by a new line and the string Yuck, foam..
If you take 1 or more sips, your beerglass should not contain anymore foam, but should show the top of your glass. Drinking the foam counts as one sip.
If you take 6 or more sips, you should output an empty beer glass, followed by a new line and the string Burp.
For each sip you take, your beer glass should become emptier. How full your beerglass is depends on the amount of bubbles ° (°) in your beer. For each sip you take after the foam, a line of bubbles should be removed. Each line of beer can contain a minimum of 1 and a maximum of 5 bubbles. The position of these bubbles should be 100% random.
Examples
input
empty input string, or no input at all
output
  oo  o oo
 oooooooooooo
o|  °     ° |\
 |     °    | \
 | °°    °  |} |
 |  °    °  | /
 |     °   °|/
 \__________/

input
sip sip sip
output
 ____________
 |          |\
 |          | \
 |     °    |} |
 |° °     ° | /
 | °    °   |/
 \__________/

input
sip sip sip sip sip sip sip sip sip sip
output
 ____________
 |          |\
 |          | \
 |          |} |
 |          | /
 |          |/
 \__________/
Burp

This pastebin contains a list of inputs and outputs. Remember that the bubbles in the beerglass should be random!
Scoring
This is code-golf, shortest code in bytes wins!
Happy drinking golfing!

You might want to note that ° is the character with code point 176.

176 in Latin-1 and Unicode, to be more specific.

Is a trailing newline on inputs except 1 and 6+ acceptable?

@ETHproductions yes. Will edit in when on laptop

By 100% random does that mean that running the same input over and over should produce different acceptable mugs, and that the distribution of bubbles should be even for each bubble spot?

The mug outputs should remain the same. The amount of bubbles on each line should differ every run. There can be only one bubble on each line, or up to 5. That's the random part of the challenge

Is the foam fixed or also random?

Japt, 189 bytes
I almost went insane while trying to get this to work properly...
U?S+'_pC +R:"  oo  o oo\n "+'opC +"\no")+"\\, \\,} |, /,/"q', £(V=(!Y«U?"|: |" +SpA +'|+X,(1+5*Mr)o mZ=>Ul <Y*4+4©(V=Vh2+A*Mr ,'° ),V)qR +"\n \\"+'_pA +'/+R+(Ul ¥3?"Yuck, foam.":Ug22 ?`B¨p:

Try it online!
(Note: This program was made for an older version of Japt, and doesn't currently work in the latest version. To get around this, the older version is specified in the URL. Unfortunately, this also means the top-right code box doesn't work.)
This is by far the longest program I have ever written in Japt. Here's a breakdown:
Step 1: Create the top of the beer mug.
U?S+'_pC +R:"  oo  o oo\n "+'opC +"\no")

           // Implicit: U = input string
           // Begin the ASCII art with:
U?S+       //  If U is not an empty string, a space +
'_pC +R:   //   "_".repeat(12) + a newline.
:"..."+    //  Otherwise, this string +
'opC +     //   "o".repeat(12) +
"\no")     //   a newline and an "o".

If U is an empty string, this makes:
  oo  o oo
 oooooooooooo
o

Otherwise, this makes:
 ____________

Step 2: Create the middle rows of the mug.
+"\\, \\,} |, /,/"q', £(V=(!Y«U?"|: |" +SpA +'|+X,

+"..."    // Add to the previous string: this string,
q', £(    // split at commas, with each item X and its index Y mapped to:
V=(       //  Set variable V to the result of concatenating:
!Y«U?     //   If Y is 0 and U is an empty string,
"|: |"    //    "|"; otherwise, " |";
+SpA      //   10 spaces,
'|+X,     //   "|", and X.

This results in the previous string plus:
 |          |\
 |          | \
 |          |} |
 |          | /
 |          |/

Step 3: Add the bubbles.
(1+5*Mr)o mZ=>Ul <Y*4+4©(V=Vh2+A*Mr ,'° ),V)

            // Note: We're still looping through the five rows at this point.
(1+5*Mr)    // Generate a random integer between 1 and 5.
o           // Create an array of this many integers, starting at 0.
mZ=>        // Map each item Z in this range to:
Ul <Y*4+4©  //  If the length of U is less than Y*4+4,
            //  (in other words, if there's less than Y+1 "sip"s)
(V=Vh   '°  //   Insert "°" at position
2+A*Mr      //    2 + random number between 0 and 9.
),V)qR      // Finally, return V, and join the five rows with newlines.

At this point, the mug looks something like this:
 ____________
 |          |\
 |          | \
 |     °    |} |
 |° °     ° | /
 | °    °   |/

Step 4: Add the final row and optional text.
+"\n \\"+'_pA +'/+R+(Ul ¥3?"Yuck, foam.":Ug22 ?`B¨p:

+"\n \\"    // Add a newline and " \".
+'_pA       // Add 10 "_"s.
+'/+R       // Add a slash and a newline.
+(Ul ¥3?    // If the length of U is 3 (i.e. 1 "sip"),
"..."       //  add the string "Yuck, foam.".
:Ug22 ?     // Otherwise, if U has a character at position 22 (six or more "sip"s),
`B¨p        //  decompress this string ("Burp") and add it.
:           // Otherwise, add nothing.

Now everything is ready to be sent to output, which is done automatically. If you have any questions, feel free to ask!

It's been 3 days. RIP brain

@Bas I had it mostly written yesterday, but it wasn't my brain so much as my browser that died ;) I'll get it written today.

I'm glad your brain is still functioning, and I'm looking forward to see an explanation of this monstrosity beautiful piece of code

@Bas Explanation is ready :-)

JavaScript (ES6), 283 281 bytes
s=>` `+(u=`_________`,(s=s&&s.split` `.length)?u+`___
 `:` oo  o oo
 oooooooooooo
o`)+(i=0,l=q=>`|`+[...u].map(_=>Math.random()>.8&i>=s&&b++<5?`°`:` `,b=0,i++).join``+(b|i<s?` `:`°`)+`|`+q+`
 `)`\\`+l` \\`+l`} |`+l` /`+l`/`+`\\`+u+`_/
`+(s&&s<2?`Yuck, foam.`:s>5?`Burp`:``)

Explanation
s=>
  ` `+(u=`_________`,        // u = 9 underscores
  (s=s&&s.split` `.length)   // s = number of sips
    ?u+`_
 `:` oo  o oo
 oooooooooooo
o`)                          // print glass top or foam

  // Print glass lines
  +(i=0,                     // i = line number
    l=q=>                    // l = print glass line
      `|`+[...u].map(_=>     // iterate 9 times
        Math.random()>.8     // should we put a bubble here?
        &i>=s                // has this line already been sipped?
        &&b++<5              // have we already placed 5 bubbles?
          ?`°`:` `,          // if not, place the bubble!
        b=0,                 // reset the number of placed bubbles
        i++                  // increment the line counter
      ).join``               // put the 9 spaces and bubbles together
      +(b|i<s?` `:`°`)       // place a bubble at 10 if none were placed
      +`|`+q+`
 `                           // print the suffix of this glass line
  )`\\`
  +l` \\`
  +l`} |`
  +l` /`
  +l`/`

  +`\\`+u+`_/
`                            // print the bottom of the glass
  +(s&&s<2?`Yuck, foam.`
    :s>5?`Burp`:``)          // print the message

Test

Input: <input type="text" id="sips" /><button onclick="result.innerHTML=(

s=>` `+(u=`_________`,(s=s&&s.split` `.length)?u+`___
 `:` oo  o oo
 oooooooooooo
o`)+(i=0,l=q=>`|`+[...u].map(_=>Math.random()>.8&i>=s&&b++<5?`°`:` `,b=0,i++).join``+(b|i<s?` `:`°`)+`|`+q+`
 `)`\\`+l` \\`+l`} |`+l` /`+l`/`+`\\`+u+`_/
`+(s&&s<2?`Yuck, foam.`:s>5?`Burp`:``)

)(sips.value)">Go</button>

PHP, 277 265 263 bytes
Assuming 1-byte-linebreak. Add one to 14 and 17 on Windows.
$r=str_pad(($i=$argc-1)?"":"  oo  o oo",16).str_pad("
 ",14,_o[!$i])."   ".($s="
 |          |")."\\  $s \\ $s} |$s / $s/
 \__________/
 ".($i<6?$i-1?"":"Yuck, foam.":burp)if(!$i){$r[34]=o;$i=1;}for(;$i++<6;)for($n=rand(1,5);$n--;)$r[17*$i+rand(2,11)]="°";echo$r;

Run with -r. line breaks may need escaping.
breakdown
// draw beer glass
$r=
    // first line: empty or foam
    str_pad(($i=$argc-1)?"":"  oo  o oo",16)
    // second line: top or foam
    .str_pad("\n ",14,_o[!$i])
    // other lines: empty glass+bottom
    ."   ".($s="\n |          |")."\\  $s \\ $s} |$s / $s/\n \__________/\n"
    // lyrics
    .($i<6?$i-1?"":"Yuck, foam.":burp)
;

// add foam left to the glass
if(!$i){$r[34]=o;$i=1;}

// add bubbles
for(;$i++<6;)
    for($n=rand(1,5);$n--;)
        $r[17*$i+rand(2,11)]="°";

// output
echo$r;

Hi, sorry for failing to answer your question in time but the foam should be fixed. However, if it improves your byte count I guess it may be random too. My bad for not clearly specifying, so use it to your advantage

@BassdropCumberwubwubwub Actually random foam costs. I just saw that everyone had it fixed while I was coding and kept mine random for a start.

source: Stack Exchange

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

sort: votes


text:
Title Keywords in Context
This challenge is based on a problem described in D. Parnas, On the criteria to be used in decomposing systems into modules, and elaborated upon in J. Morris, Real Programming in Functional Languages.
Write a program or function which takes a list of book titles from stdin or as an argument, in a reasonable, convenient format for your language. For example,
Green Sleeves
Time Was Lost

or
("Green Sleeves";"Time Was Lost")

Return or print to stdout an alphabetized list of the keywords, showing their context within the original titles by enclosing each keyword in angle braces (< and >). As with input, output can be in a reasonable format which is convenient for your language- newline-separated lines, a list of strings, etc:
<Green> Sleeves
Time Was <Lost>
Green <Sleeves>
<Time> Was Lost
Time <Was> Lost

Titles will consist of a series of keywords separated by a single space. Keywords will contain only alphabetic characters. Keywords are to be sorted lexicographically. Titles will be unique, and keywords will be unique within each title but the same keyword may exist in several titles. If a keyword exists in more than one title, the output should list each appearance in an arbitrary order. For example, given this input:
A Dugong
A Proboscis

A valid output would be either:
<A> Proboscis
<A> Dugong
A <Dugong>
A <Proboscis>

Or:
<A> Dugong
<A> Proboscis
A <Dugong>
A <Proboscis>

This is code-golf- the winner is the shortest solution in bytes. Standard loopholes are disallowed.

What about if the same keyword occurs more than once in a title? Should the occurrences be in order of appearance, or is arbitrary order permitted?

@PeterTaylor: from the spec, "Titles will be unique, and keywords will be unique within each title…"

Pyth, 25 24 22 bytes
VSsm,Rdcd\ QAN:HGjG"<>

Try it online.
Takes input as an array of lines, like ["Green Sleeves","Time Was Lost"].
Explanation
VSsm,Rdcd\ QAN:HGjG"<>   implicit: Q = evaluated input

   m       Q                   map input lines:
       cd\                         split input line to words
    ,Rd                          replace each word by pair [word, entire line]
  s                          concatenate results for all input lines
 S                         sort the array of pairs lexicographically
V                        loop over the array
            AN             assign the word to G and the corresponding line to H
                 jG"<>       put the word between <>
              :HG          replace the word by the above in the line and print

Looks buggy - check the handling of title Time Was Time.

@PeterTaylor Quoting from the OP, keywords will be unique within each title.

Japt, 55 bytes
Perhaps this could be made shorter, but I'm not sure how...
P+UqR £XqS m_+S+X) q', n £Xs1+XbS)rXs0,XbS),@"<{X}>")qR

How it works
P+UqR m@XqS m_+S+X) q', n m@Xs1+XbS)rXs0,XbS),@"<{X}>")qR
          // Implicit: U = input string, S = a space, P = empty string
UqR m@    // Split input at newlines, then map each item X to:
XqS m_    //  X split at spaces, with each item Z mapped to:
+S+X)     //   Z + a space + X.
P+   q',  // Parse the result as a string, and split at commas. Due to JS's default
          // array-to-string conversion (joining with commas), this flattens the array.
n         // Sort the result lexicographically.
m@Xs1+XbS // Map each item X to everything after the first space,
rXs0,XbS  // replacing the original keyword with
@"<{X}>"  // "<" + keyword + ">".
qR        // Join the result with newlines.
          // Implicit: output last expression

CJam, 41 36 32 bytes
q~{:AS/{A1$/"<>"@**}/}%{'</1=}$p

Test it here.

Haskell, 113 bytes
import Data.List
g l=[(m,h++('<':m++['>']):t)|(h,m:t)<-zip(inits l)$tails l]
f=map(unwords.snd).sort.(>>=g.words)

Usage example: f ["Green Sleeves","Time Was Lost"] -> ["<Green> Sleeves","Time Was <Lost>","Green <Sleeves>","<Time> Was Lost","Time <Was> Lost"].

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


text:
Check my program!
Challenge
Make an error-checker in the least amount of possible bytes! If you received an HTML program as a string through standard input, your program will be able to find all the errors and return to standard output. If the program is over 2000 characters, return that as an error too.
Errors
As there has been discrepancy, I will provide the errors you can check for.
Regular:

File too long
Tag not closed
Non-empty element not closed

XHTML self-closing will not give you any bonus.

Entity not closed (i.e. &amp vs &)
CSS rule with no selector attached (i.e. {color:white;} vs span {color:white;}
CSS unclosed property-value pair (i.e. color:white vs color:white;)
Errors with brackets (e.g. no closing bracket, rules outside brackets, etc.)

Each different rule about brackets counts separately.

Undefined tag (worth x10)
Undefined attribute (worth x4)
Undefined CSS property (worth x10)

Let me make this clear:
You are not expected to complete all or even most of these.
Completing 7 of them would be incredible, but not necessary. Please though, try as many as you can while keeping the byte count relatively low!
Scoring

-10 bytes for every type of SyntaxError checked (e.g. undefined tag, oversized file [see above], etc.)
-30 bytes for every type of SyntaxError checked that returns a customized error message and line number. (for a total of -40 bytes per error)

You may not have a customized message less than 20char.

-100 bytes if your program can check embedded CSS in the document for at least 3 types of errors. (this includes <element style=""> and .
+100 bytes if you check only 3 or less types of errors.
~0 bytes if your final score is negative.

As this is my first code-golf challenge, please comment if you think the scores are out of range.
Rules

You may not use a built-in function to check for errors.
You must check for at least 1 error type. No blank answers! :D
You must return at minimum the number of errors in the document.
When you post your score, you should use this Markdown format:
Output:

My Language, Unbonused bytes Final Score
code here

Solves:

First Error
Second Error
Et Cetera

Why/How it works

       Markdown:
# My Language, <s>Unbonused bytes</s> Final Score #
    code here
**Solves:**
* First Error
* Second Error
* Et Cetera
Why/How it works

* You may add additional strikethroughed numbers if you wish in between the two values.
Winning
After one week, the answer with the smallest number of bytes will win. If there is a tie, the answer with the most upvotes will win. If there is still a tie, I hold the divine power to choose. The winning answer will be accepted.
After the deadline, others can still post their answers, but no reward will be given.
Good Luck!
This is my first challenge, so if anything is lacking in any way, please comment. Thank you!

-1 too many bonuses. Scoring should be simple.

You should add some example HTML programs for testing.

@Mego To me, this seems like a complicated challenge, so IMO there should be bonuses to bring the bytes back down. Also, there are literally 3 different bonuses: You dock 10 bytes if you check an error, and an additional 15 for customizing it. You dock 100 if you check CSS too. You add on 100 for cheaping out. If your score is negative, you go back to 0. Simple.

@LegionMammal978 I will, but not yet. I want to wait a while, maybe at least a day.
EDIT: My reasons for that? Not saying nuthin'.

Also, are we allowed to check for errors that merely cause XHTML non-compliance (such as
 instead of
)?

This is specifically HTML, so I would say no. You could do it, but I just wouldn't give you any bonus for it.

Considering that most challenges are scored by the byte count of the solution (without any modifications), this is anything but simple.

Have you tried to solve the task by yourself? Writing a full DOM-parser is not an easy challenge. There are many tags, many attributes many levels and ways of nesting. This can very fast become huge and complex.

I never said it was easy. >:)

If we aren't testing for XHTML, what should we test for? Different browsers allow different errors.

Any errors that are errors in HTML (E.G. not closing tags that should be closed, unclosed strings, etc.) as well as the 2000char limit I used.

...you just restated the XHTML standard.

What I'm saying is you don't need to do things that are only in XHTML, such as closing empty elements (i.e. ), uppercase tags (i.e.  not ) etc.

Under what curcumstance does the custom error method with line number bonus apply to size checking.

You don't to provide a non-existent line number. Just give a custom error message that's intuitive (e.g. not just "l") It should be at least 20char long. Adding that to OP now.

I'm voting to close as "Unclear what you're asking" because "every type of SyntaxError checked" is far too vague for a spec. If you gave 10 programmers a copy of e.g. the HTML 4.0 spec and asked them how many possible syntax errors there are, you would get at least 10 different answers.

@Peter I don't think you understood what I meant. I used "every" to mean "each", not "all".

Yes, I understood that. My point is that the number of errors checked by a serious error-checking program is highly debatable. I might claim that X, Y, and Z are three different types of errors, whereas someone else might claim that they're really all the same error.

So really, you want us to write a DOM parser that can handle malformed input by definition and unambiguously mark where it went wrong? I'm sorry, but I want to be paid by the hour before going there.

The "specific error message" bonus is never worth obtaining, because it is only worth 15 bytes and the error message needs to be at least 20 bytes.

Oh :$ sorry. Changing that now.

@PeterTaylor,@sanchises You don't need to comprehensively solve every single error. Keep it simple! Strategy: Do 4 different types so you don't get the penalty, but it is still keeping the bytes relatively low.

I have clarified the allowed errors, comment if I left any out.

I'm surprised that in the time since this was posted nobody asked about Parsing the HTML with Regex.

Unefunge 98, 15 9  - 10(1 error type) 36 bytes - 40(one error with detatiled message) + 100 (only one error type) = 105 99 96
This code only checks the file size.
'Ϩ#@k~"elif rellams a edivorP<NAK>"k,1q

Note that the code above contains a unicode number with code point 2000 (counted as two bytes) and an unprintable character with character code 21 (negative ackoledgement) represented by <NAK>. The error message produces is "Provide a smaller file".
Old 15-byte version:
2aaa***#@k~1q

How it works:
The programs 2aaa*** (in the old version) and  'Ϩ push the number 2000 on to the stack. Then the # character jumps over the @ and k extecutes ~, getting a char from user input, 2000 times. If eof is read, ~ reflects the program onto the @ terminating with a zero exit code. If no eof is encountered, 1q exits with exit code 1, indicating that there is one error in the input (its too big).

Good! Impressed with the way you dealed with the simplicity penalty!

@OldBunny2800 What do you mean by "Impressed with the way you dealed with the simplicity penalty"? That penalty really skyrockets my score.

I mean how you still got less than 100 even with a +100 penalty.

@OldBunny2800 Although every answer gets at least -10 in bonuses (they have to handle at least one error), so the peanlty is really -90.

Good point, but still.