text:
Is it a balanced number?
A number is balanced if the sum of the digits on each half of the number is equal, so: 1423 is balanced because 1+4 = 2+3, so is: 42615 because 4+2=1+5. Note that the middle digit is not included on either side (or it's included on both sides) if there's an odd number of digits.
Challenge:
Take a positive integer as input, and output a truthy value if it's balanced and a falsy value if it's unbalanced.
Test cases (true)
1
6
11
141
1221
23281453796004414
523428121656666655655556655656502809745249552466339089702361716477983610754966885128041975406005088

Test cases (false)
10
12
110
15421
5234095123508321
6240911314399072459493765661191058613491863144152352262897351988250431140546660035648795316740212454

There will not be numbers starting with zero, for instance 00032 instead of 32. You must support numbers up to at least 100 digits (so larger than 2^64-1). As always, optional input format, so you may surround the number with apostrophes if desired.

05AB1E, 14 7 bytes
€D2äO`Q

Explanation
Using 141 as example:
€D       # duplicate each (turns the number into a list of digits)
         # STACK: ['1','1','4','4','1','1']
  2ä     # split list in 2 (as we duplicated each element,
         # the middle element will exist on both sides for an odd length input
         # STACK: [['1','1','4'],['4','1','1']]
    O    # sum each sublist
         # STACK: [6,6]
     `   # flatten
         # STACK: 6, 6
      Q  # compare for equality
         # STACK: 1 (true)

Try it online!

Can't you use Ë instead of \Q`?

@EriktheOutgolfer: Ë was a different command back when this challenge was made, so unfortunately not.

><>, 31 29 bytes
i:0(?v
~00}v>
v+r+>l4(?
>{=n;

Try it online!
Line 1: Standard input loop
Line 2: Discard the -1 on top of the stack, push two 0's and rotate one to the bottom of the stack (this ensures that inputs of length <3 don't exhaust the stack later in the program)
Line 3: If the length of the stack is >3, add the top two and bottom two elements of the stack together.
Line 4: If top and bottom of the stack are equal, output 1, 0 otherwise.
Edit: realised that there's no need to take the characters mod 12, 2 bytes saved

Haskell, 64 63  bytes
b(a:t@(r:s))=a-last t+b(init t);b _=0
(==0).b.map fromEnum.show

One Byte Saved thanks to nimi

Don't snippets need parentheses?

@michael-klein No, unnamed function are allowed. http://meta.codegolf.stackexchange.com/a/7615/20260

One byte to save: b(a:t@(r:s))=a-last t+b(init t);b _=0

Brachylog, 20 bytes
@eL@2tM,Lr@2t:M:+a#=

Try it online!
Explanation
@eL                    Get the list of digits L of the input
  L@2tM,               Get the second half M of L
        Lr@2t          Get the second half of the reverse of L
             :M        The list [L, M]
               :+a#=   The sum of elements of L and the sum of elements of M must be equal

Mathematica, 57 bytes
Tr@(#-Reverse@#)[[;;⌊Length@#/2⌋]]==0&@*IntegerDigits

Explanation
I was really hoping I could use this approach in some language, and it seems to be doing fairly well in Mathematica. The idea is to avoid having to obtain both the front and the back half by combining the list with its reverse and looking only at the front half.
...&@*IntegerDigits

First, we turn the input into a list of decimal digits and pass the result to the unnamed function on the left.
...(#-Reverse@#)...

Now we subtract the reverse of the list from the list itself. If the digits are {a1,a2,...,an} then the result will be {a1-an,a2-an-1,...,an-a1}.
...[[;;⌊Length@#/2⌋]]

We extract the first half of this list (excluding the middle digit although that doesn't actually matter, because the corresponding difference will be 0 anyway).
Tr@...

And then we sum this list. So that's:
a1 - an + a2 - an-1 + ... + a⌊n/2⌋ - a⌈n/2⌉+1
Rearranging:
a1 + a2 + ... + a⌊n/2⌋ - (a⌈n/2⌉+1 + ... + an-1 + an)
The input is balanced if the two halves have the same sum. Hence, this expression is zero if the input is balanced. So that's what we check:
...==0

Haskell, 55 bytes
g(h:t)=read[h]-g(reverse t)
g _=0
(==0).g.(<*"xx").show

The recursive function g unwraps a number string from both ends by repeatedly taking the head, then reversing. It subtracts the recursive result from the head, which causes it alternate coefficients of +1 and -1, with +1 applied to the first half and -1 to the second half.
   g "12345"
== 1 - g "5432"
== 1 - (5 - g "432")
== 1 - (5 - (4 - g "32"))
== 1 - (5 - (4 - (3 - g "2"))
== 1 - (5 - (4 - (3 - 2))
== 1 + 2 + 3 - 4 - 5

So, it takes the sum of the first half minus the sum of the second half. This has the issue that with an odd number of digits, the center tiebreaks to the left, but the main function fixes that by (<*"xx"), which doubles every character, i.e. "12345" becomes "1122334455". That way the middle digit splits evenly on both sides and cancels out.

Java, 85 bytes
n->{int s=0,i=0,l=n.length();for(;i<l/2;)s+=n.charAt(i)-n.charAt(l-++i);return s==0;}

Note: the input is given as String as Java can't handle without BigInteger (and BigIntegers are constructed using a... String.)
Testing and ungolfed:
import java.util.function.Predicate;

public class Main {

  public static void main(String[] args) {
    Predicate<String> f = n -> {
      int s = 0, i = 0, l = n.length();
      for (; i < l / 2;) {
        s += n.charAt(i) - n.charAt(l - ++i);
      }
      return s == 0;
    };

    String[] truthies = {"1",
      "6",
      "11",
      "141",
      "23281453796004414",
      "523428121656666655655556655656502809745249552466339089702361716477983610754966885128041975406005088"};
    for (String s : truthies) {
      boolean result = f.test(s);
      System.out.println(result);
    }
    String[] falsies = {"10",
      "12",
      "110",
      "15421",
      "5234095123508321",
      "6240911314399072459493765661191058613491863144152352262897351988250431140546660035648795316740212454"};
    for (String s : falsies) {
      boolean result = f.test(s);
      System.out.println(result);
    }
  }
}

Nice answer. You could save 2 bytes by making the for-loop empty: for (; i < l / 2;s += n.charAt(i) - n.charAt(l - ++i));.

@todeale Look at the golfed code, not the ungolfed one. I think your suggestion and my golfed answer use the same amount of bytes

Ooops! Now I see.

JavaScript (ES6), 59 55 51 44 42 bytes
f=([x,...a],n=0)=>a[0]?f(a,x-a.pop()+n):!n

Turns out I was using the wrong strategy entirely. This version recursively finds the sum of the first half minus the sum of the second half, then returns the logical NOT of the result.
If we could return falsy in place of truthy and vice-versa, this would be 35 bytes:
f=([x,...a])=>a[0]?x-a.pop()+f(a):0

Test snippet

f=([x,...a],n=0)=>a[0]?f(a,x-a.pop()+n):!n
<input id=I value="23281453796004414"><br>
<button onclick="console.log(`Result of f(${I.value}): `+f(I.value))">Run</button>

I really like this n[i*2]!  Nice one.

@Arnauld Thanks :-) I've found a completely different approach now that doesn't need that at all...

Now, that's brilliant!

Can't you use f=([x,...a])=>!(a[0]?x-a.pop()+f(a):0)?

@mbomb007 Nope; that would return a boolean (coerced to 0 or 1) after every recursion, rather than a sum.

Python 3, 107 102 76 bytes
n=input()
l=len(n)
print(sum(map(int,n[:l//2]))==sum(map(int,n[l//2+l%2:])))

-26 bytes by @Rod!

you can replace floor(l/2) with l//2 and ceil(l/2) with l//2+l%2 to save 7 bytes, and then remove the math import, saving more 18

also you don't need the 0 on n[0:l//2] and n[l//2+l%2:] could just be n[-(l//2):]. Or you could move the //2 to l=len(n)//2 and use n[:l] and n[-l:]

It also looks really weird when your import isn't at the top.

@Rod I came here to change all the things you mentioned on the first comment, but was amazed by the second one, thanks a lot! :)

@Rod By using your last tip on your second comment, the single digit testcases return falsey values :(

PowerShell v2+, 85 bytes
param($a)!((,'('+$a[0..(($b=$a.length)/2-1)]+'0)-('+$a[($b/2)..$b]+'0)')-join'+'|iex)

Takes input $a as a string (necessary to support numbers >2^64-1 without getting into extremely clunky [biginteger] casting on the command line).
For the explanation, let's assume input of '1423'. We're then constructing a new string. The two array slices are obvious ($a[...]), and that's surrounded by three additional strings (, 0)-(, and 0), formulating an array of chars and strings. Note the , at the front to enforce array concatenation, not string concatenation.
That whole array is -joined together with +, resulting in a string like (+1+4+0)-(+2+3+0), and you can see that the 0s are needed to prevent syntax errors. That's fed into |iex (short for Invoke-Expression and similar to eval), which will compute the mathematical result. So long as the string is balanced, you'll get 0 as an output, which we encapsulate in parens and take the Boolean-not thereof !(...), to output True. If it's any non-zero integer, it'll output False.
Test Cases
PS C:\Tools\Scripts\golfing> '1','6','11','141','23281453796004414','523428121656666655655556655656502809745249552466339089702361716477983610754966885128041975406005088'|%{$_;.\is-it-a-balanced-number.ps1 $_;'---'}
1
True
---
6
True
---
11
True
---
141
True
---
23281453796004414
True
---
523428121656666655655556655656502809745249552466339089702361716477983610754966885128041975406005088
True
---

PS C:\Tools\Scripts\golfing> '10','110','15421','5234095123508321','6240911314399072459493765661191058613491863144152352262897351988250431140546660035648795316740212454'|%{$_;.\is-it-a-balanced-number.ps1 $_;'---'}
10
False
---
110
False
---
15421
False
---
5234095123508321
False
---
6240911314399072459493765661191058613491863144152352262897351988250431140546660035648795316740212454
False
---

C#, 83 bytes
n=>{var t=n+"";int l=t.Length,i=0,r=0;for(;i<l/2;)r+=t[i]-t[l-1-i++];return r==0;};

Try it online!
Full source, including test case:
using System;
using System.Numerics;

namespace BalancedNumber
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<BigInteger,bool>s= n=>{var t=n+"";int l=t.Length,i=0,r=0;for(;i<l/2;)r+=t[i]-t[l-1-i++];return r==0;};

            Console.WriteLine(s(1));    //true
            Console.WriteLine(s(6));    //true
            Console.WriteLine(s(11));   //true
            Console.WriteLine(s(141));  //true
            Console.WriteLine(s(23281453796004414));    //true
            BigInteger bi = BigInteger.Parse("523428121656666655655556655656502809745249552466339089702361716477983610754966885128041975406005088");
            Console.WriteLine(s(bi));   //true
            Console.WriteLine(s(10));   //false
            Console.WriteLine(s(12));   //false
            Console.WriteLine(s(110));  //false
            Console.WriteLine(s(15421));    //false
            Console.WriteLine(s(5234095123508321)); //false
            bi = BigInteger.Parse("6240911314399072459493765661191058613491863144152352262897351988250431140546660035648795316740212454");
            Console.WriteLine(s(bi));   //false
        }
    }
}

The BigInteger data type allows any number length. If the number is too large, the compiler complains (error CS1021: Integral constant is too large), so the BigInteger.Parse(String) method is used instead.
The solution can actually be reduced to 72 bytes considering the input is a string (and updating the program accordingly):
t=>{int l=t.Length,i=0,r=0;for(;i<l/2;)r+=t[i]-t[l-1-i++];return r==0;};

Not surprisingly, my c answer ended up looking fairly similar to this one.  Can you do t[l-++i] instead of t[l-1-i++], and return !r instead of return r==0?

Prefixing the increment operator should do the trick and save 2 bytes, but in C# the return value must be a boolean, so !r won't cut it. Thanks, I'll update my answer as soon as possible.

Ruby, 63 bytes
->s{e=s.chars*?+
l=s.size
e[l-1-r=l%2,2*r+1]="=="
l<2||eval(e)}

Note: arg s must be string.
Testing(minitest 5+ required):
require 'minitest/autorun'

class TestRunner < Minitest::Test
  def setup
    @truthy_nums = %w(1 6 11 141 23281453796004414 523428121656666655655556655656502809745249552466339089702361716477983610754966885128041975406005088)
    @falsy_nums = %w(10 110 15421 5234095123508321 6240911314399072459493765661191058613491863144152352262897351988250431140546660035648795316740212454)

@f=->s{e=s.chars*?+
l=s.size
e[l-1-r=l%2,2*r+1]="=="
l<2||eval(e)}

  end
  def test_true
    @truthy_nums.each do |e|
      assert @f[e], e
    end
  end
  def test_false
    @falsy_nums.each do |e|
      assert !@f[e], e
    end
  end
end

Perl, 29 bytes
Includes +5 for -lpF
Give number on STDIN
balanced.pl <<< 1423

balanced.pl:
#!/usr/bin/perl -lpF
$;+=$_-pop@F for@F;$_=!$

Vyxal, 4 bytes
YIṠ≈

Try it Online!
Beats all other answers.
How?
YIṠ≈
Y     # Interleave the input with itself, giving a list with each digit duplicated
 I    # Split into two halves
  Ṡ   # Sum each
   ≈  # Is this list all equal?

05AB1E, 6 bytes
.ι2äOË

Try it online!
Same concept.

Funnily enough, this is also exactly what this Jelly answer does, despite it being a port of the 05AB1E answer yours beats!

Actually, 17 16 bytes
This answer is inspired by ElPedro's Python 2 answer and their idea to use [-b:]. Golfing suggestions welcome. Try it online!
$♂≈;l½L│±aHΣ)tΣ=

Ungolfing
      Implicit input n.
$♂≈   list(str(n)). This converts n to a list of n's digits.
;l    Duplicate the list of digits and get its length. Call it len.
½L    Push len//2.
│     This duplicates the stack.
        Stack: len//2, digit_list, len//2, digit_list
±     Negate the len//2 at TOS for later.
a     Invert the stack.
        Stack: digit_list, len//2, digit_list, -(len//2)
HΣ    Push digit_list[:len//2], then push its sum.
)     Rotate this first sum to BOS.
tΣ    Push digit_list[-(len//2):], then push its sum.
=     Check if those sums are equal.
      Implicit return.

Brain-Flak, 410 206 204 178 + 3 = 181 bytes
Here is a 178 byte version that uses the -a flag.
26 bytes golfed off by DJMcMayhem
Try it Online
([])(<(()()(<>))>)<>{({}[()])<>(({}()[({}<({}())>)])){{}(<({}({}<({}[()])>))>)}{}<>}{}<>{}{}({}<>){({}[()]<({}<>)<>>)}{}([]<>[[]]<>){(<{}{}>)}{}({{}<>[{}]<>}<(())>){{}{}((<>))}{}

Here is a longer 410 byte version that does not use the -a flag.
Try it Online
{(({}))(<((()()()()()){}<>)>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}{}<>({}<{}>)<>(<((()()()()()){}(<>))>)<>{({}[()])<>(({}()[({}<({}())>)])){{}(<({}({}<({}[()])>))>)}{}<>}{}<>{}{}({}<>)}{}<>([])(<(()()(<>))>)<>{({}[()])<>(({}()[({}<({}())>)])){{}(<({}({}<({}[()])>))>)}{}<>}{}<>{}{}({}<>){({}[()]<({}<>)<>>)}{}([]<>[[]]<>){{}{}(<>)}{}(([])<>)({<{}>{}<([])>}{}<>[{<{}>{}<([])>}{}]<(())>){{}{}((<>))}{}

Explanation
Here is an explanation of the shorter solution
To begin the number is converted to all of its ASCII values by the -a flag.
We push the stack height (i.e. number of digits) and divide by two.
([])(<(()()(<>))>)<>{({}[()])<>(({}()[({}<({}())>)])){{}(<({}({}<({}[()])>))>)}{}<>}{}<>{}{}({}<>)

For each number less than the number we just pushed we move a digit to the other stack
{({}[()]<({}<>)<>>)}{}

If the stacks have different heights we remove the top item from the current stack
([]<>[[]]<>){(<{}{}>)}{}

We want the difference between the sums of each stack.  So we use the following algorithm to sum each stack.
{{}}

This assumes no digit has an ASCII value of zero, which is a valid assumption.
We run this for both stacks and take the difference (The <(())> is necessary for the next part.
({{}}<>[{{}}]<(())>)

We now want to negate the sum.  If the sum is zero it will pop the top off revealing the one we pushed earlier otherwise it will remove both the number and the one and place a zero on top.
{{}{}((<>))}{}

Why use ([]){[{}]{}([])}{} to sum each stack? ({{}}) should work just fine, and since you're taking ASCII input, you don't have to worry about 0's ruining the loop.

@DJMcMayhem Good point.  I forgot there couldn't be a zero on the stack

Retina, 64 44 bytes
^((.)*?).?(?=(?<-2>.)*$)
$1
\d
$*
^(1+) \1$

Try it online
The first stage splits the string in the middle, omitting the middle character if there is one (taken and modified from here. Courtesy of Martin.) Then, replace digits with their unary representation, and match if the two halves are of equal length.

Why would you use a non-capturing group in a code golf? ;) Regardless, in .NET it's much shorter to split the string with balancing groups: http://retina.tryitonline.net/#code=XigoLikqPykuPyg_PSg_PC0yPi4pKiQpCiQxLA&input=MjMyODE0NTM3OTYwMDQ0MTQ (I also tried multiple stages but that ends up slightly longer http://retina.tryitonline.net/#code=XGIKLAorYCwoLikoLiopKC4pLAokMSwkMiwkMw&input=MjMyODE0NTM3OTYwMDQ0MTQ).

@MartinEnder Yeah, I knew it would be, but I never really grasped the concept. And I suppose I overlooked the non-capturing group.

It's really simple in this case: we count characters with (.)*? (each iteration pushes a capture onto stack 2). Then we try to reach the end by popping from the stack again with (?<-2>.)*$ (after an optional middle digit). The first time this is possible is when we've captured exactly half the digits (rounded down) into group 2.

JavaScript (ES6), 74 67 ... 59 50 bytes
Recursively sums the difference of the first and last digits until there's less than two digits left:

let f =

n=>!(F=n=>n[1]?(n.pop()-n.shift()+F(n)):0)([...n])

// some truthy examples
console.log(f("11"));
console.log(f("141"));
console.log(f("523428121656666655655556655656502809745249552466339089702361716477983610754966885128041975406005088"));

// some falsy examples
console.log(f("12"));
console.log(f("110"));
console.log(f("6240911314399072459493765661191058613491863144152352262897351988250431140546660035648795316740212454"));

Nice technique. I think you can do (s-=i<0?v:-v).

@ETHproductions - Interesting to see how close the methods with and without Math.sign() turn out to be.

Darn, you may have beaten me for good... nice one :)

I was wrong ;-)

R, 105 96 bytes
Turns out R is very verbose. Takes input as a character.
function(x){y<-as.numeric(unlist(strsplit(x,"")));l<-length(y)%/%2;sum(tail(y,l))==sum(head(y,l))}

Formatted nicely:
function(x){
    y=as.numeric(unlist(strsplit(x,"")))
    l=length(y)%/%2
    sum(tail(y,l))==sum(head(y,l))
}

Explanation

y<-as.numeric(unlist(strsplit(x,""))) Split the input (a string_, and coerce it to a vector instead of a list, and then turn it back into integers.
sum(tail(y,:         tail takes the last n elements, found by:

length(y)%/%2)), where %/% is integer division, to get the ceiling of the quotient, where the length is odd.

sum(head(y,length(y)%/%2)): like tail, head takes the first n elements of the vector, found in the same way.

Edits

Saved seven bytes thanks to niam
Switched to = instead of <- , saved another two bytes.

Can you bind length(y)%/%2 somehow to a variable and use that within the calls of tail and head?

@nimi Oh yeah, good point.

85 bytes
https://tio.run/##NZDbasMwDIbv9xiBggPtprOt0jxMR7O2kG0lSWF5@kxpG2OsX7IOn93P52a@9VO/33@l4f6dxuO1S9NhdxzeT7/3z65NbZeGsR9u3XVMf9uqqut62x12XftzHi9pqjcfG6rrplmqL@3xlKZtFznzOVVY1W9h7Gnw5aKsguiliKmgKGc3ABGUZ1iJJS4ITW1ZqrHjeAhToAKeRUlc4zBjdiiegdgwo0nOXkJCVnGzUhSjQtDDhxikUEoMeqDAirSyrgGVFXKhAY8eHIW8Ro0iiMgo7A6ZRF2c80KM6AhaDFkci0WKYDRRIqPAZEUvhRSEEQU0HhBQrCYluzJaFiCMhvEb8z8

by consolidating y and l into the first sum, changing as.numeric to as.double(), unlist() to el(). This allowed me to do it all in one line, removing brackets, and  pryr::f guesses the formals/variables from the code

Perl 6,  42 39  33 bytes
{[==] .comb[{^($_/2),Int($_/2)..*}]>>.sum}

Test it
{[==] .comb[^(*/2),(*/2).Int..*]>>.sum}

Test it
{[==] .comb[^*/2,^*/2+*/2]>>.sum}

Test it (from Jo King)
Explanation:
{ # lambda with implicit parameter ｢$_｣

  [==]                   # reduce the following using &infix:«==»

    .comb\               # split input into individual characters
    [                    # index into that using:

      # first half of the values (includes middle value)
      # ｢(0/2) ..^ (*/2)｣
      ^ * / 2,

      # last half of the values (includes middle value)
      ^ * / 2            # same number of values as first half
        + * / 2          # shifted up by half

    ]\
    >>.sum               # sum each of the two halves separately
}

This doesn't seem to work anymore (I suspect a change in how .. handles non-integers). How about 33 bytes instead

Python 2, 73 bytes
def f(n):x=map(int,str(n));d=len(x)/2;print sum(x[:d])==sum(x[-d:])or d<1

Tests are at ideone
We have to use str() rather than `` since n may be outside the range of signed int.

Ah, that's why I was getting the L at the end. +1

PHP, 73 67 60 57 bytes
Requires PHP 7.1 for negative string offsets:
for(;2*$x<strlen($a=$argn);)$s+=$a[$x++]-$a[-$x];echo!$s;

Run:
echo 15324 | php -nR 'for(;2*$x<strlen($a=$argn);)$s+=$a[$x++]-$a[-$x];echo!$s;';echo

Previous version
Note: requires PHP 7 for the spaceship operator.
for(;$x<$l=strlen($a=$argv[1]);)$s+=(2*$x<=>$l-1)*$a[$x++];echo!$s;

Run like this:
php -d error_reporting=30709 -r 'for(;$x<$l=strlen($a=$argv[1]);)$s+=(2*$x<=>$l-1)*$a[$x++];echo!$s;' -- 15324;echo

Explanation
Iterates over the digits in the number. Checks if the digit belongs to the first half or the second half (or is the middle digit) by comparing the digit's index to the length of the input with combined comparison (2 * $x <=> $l - 1). Then multiply that with the digit, take the sum of all digits. If it's a balanced number, the sum will be 0.
Example with input 15324:
  index     0  1  2  3  4
  digit     1  5  3  2  4

  2*index   0  2  4  6  8
  length-1  4  4  4  4  4
  factor    1  1  0 -1 -1  # Result of the spaceship operator

  result    1  5  0 -2 -4
           --------------
  sum                   0

Tweaks

Don't set the digit to $d, just iterate the length of the input. Saved 5 bytes.
String offset null doesn't have to be cast to int for PHP to interpret it as 0. Saved 1 byte.
Using negative string offsets to get the digits from the second half and iterating to half of the string. Saved 7 bytes, but requires PHP 7.1
Saved 3 bytes by using $argn

Python 2, 83 77 bytes
g=[int(h)for h in raw_input()];b=int(len(g)/2);print sum(g[:b])==sum(g[-b:])or b==0

EDIT
reduced to 77 with help from @Rod
g=[int(h)for h in raw_input()];b=len(g)/2;print sum(g[:b])==sum(g[-b:])or b<1

Examples:
D:\>bal.py
1
True

D:\>bal.py
6
True

D:\>bal.py
523428121656666655655556655656502809745249552466339089702361716477983610754966885128041975406005088
True

D:\>bal.py
10
False

D:\>bal.py
110
False

D:\>bal.py
 6240911314399072459493765661191058613491863144152352262897351988250431140546660035648795316740212454
False

you can use map(int,input()) instead [int(h)for h in raw_input()], len(g)/2 will always be int, no need to convert, and or b==0 ins't really necessary

in fact the b==0 is needed for len=1, but you can shorten it to b<1

Javascript, 73 bytes
Good ol' ES5 loops

for(a=c=0,b=(l=(s=prompt()).length)-1;a<~-l/2;c-=s[a++]-s[b--]);alert(!c)

What's happening here?
for(
    a=c=0,               // a = left digits of the number
                         // c = the result
    b=                   // b = right digits of number
        (l=              // l = length of number - 1
            (s=prompt()) // s = the number as input from user
        .length)-1;

    a<~-l/2;             // while a < length of number / 2, rounded down (~-)

    c-=
        s[a++]           // c -= left digit
        -
        s[b--]           // c += right digit (because - and - == +)
 );
                         // for balanced numbers c should be 0
 alert(!c)               // 0 equals false in javascript, so output the opposite of c

Clojure, 66 64 bytes
Update: Took str out from the map int function.
(comp #(=(apply +(map -(drop(/(count %)2)%)%))0)#(map int %)str)

This would have been shorted if the input format was more flexible, now I had to first map the integer into a sequence of ASCII values. The inner map calculates pair-wise differences of values from the two halves, and this checks if the sum of deltas is zero.
((comp f g h) x y z) = (f (g (h x y z)).
Actually this ended up being the same length as just doing the mapping within a let and just define a single function.

Factor + math.unicode sequences.repeating, 32 bytes
[ 2 repeat halves [ Σ ] same? ]

Try it online!
            ! "141"
2 repeat    ! "114411"
halves      ! "114" "411"
[ Σ ] same? ! t

C (GCC), 66 bytes
char*c,*d;i;f(s){for(d=index(c=s,i=0);c<--d;)i+=*c++-*d;return!i;}

Try It Online!
Explanation:
char*c,*d;i;
f(s)
{
    // d = the first null-terminator in s, c = s, i = 0
    // Before the first and after each iteration, decrement d and break out of
    // the loop if c has surpassed d.
    for(d=index(c=s,i=0);c<--d;)
        // Add the ascii values of c and d to i, increment c.
        // The ascii values of a number equals the ascii value of 0 plus the
        // number, so if numbers j and k are respectively stored in c and d,
        // *c - *d = (i + '0') - ('j + '0') = i - j = the signed difference
        i+=*c++-*d;
    // If the sum of the signed differences are 0, return 1; otherwise 0
    return!i;
}

Pyke, 20 bytes
[QleQ`)>[R<]mmbms$X!

Try it here!

@WeeingIfFirst you were right - I forgot not [0] was 0 not 1

Mathematica, 69
Tr@#[[;;⌊l=Length@#/2⌋]]==Tr@#[[⌈l⌉+1;;]]&@*IntegerDigits

You can save a couple of bytes by changing the end to ...;;]]&@*IntegerDigits

@MartinEnder thanks, but how does this work?

@* is short for Composition. f@*g is f[g[##]]&.

Racket 204 bytes
(define(f n)(let*((s(number->string n))(g(λ(x y)(apply +(map(λ(x)(string->number(string x)))
(string->list(substring s x y))))))(l(string-length s))(h(/ l 2)))(if(=(g 0(floor h))(g(ceiling h)l))#t #f)))

Detailed version:
(define (f1 n)
(let* (  (s (number->string n))
         (g(λ(x y)
              (apply + (map
                        (λ(x)
                          (string->number
                           (string x)))
                        (string->list
                         (substring s x y))))))
         (l (string-length s))
         (h (/ l 2)))
    (if(= (g 0 (floor h)) (g (ceiling h) l))
       #t #f  ) ) )

Testing:
(f 23281453796004414)
(f 523428121656666655655556655656502809745249552466339089702361716477983610754966885128041975406005088)
(f 15421)
(f 5234095123508321)

Output:
#t
#t
#f
#f

sed (165 + 1 for -r) 166
/^.$/c1
:l;s,^([^!])([^!]*)([^!])!?([^=]*)=?(.*),\2!\4\1=\5\3,;tl;:
s,.?!|0,,;s,2,11,;s,3,21,;s,4,31,;s,5,41,;s,6,51,;s,7,61,
s,8,71,;s,9,81,;t;s,1=1,=,;t;/^=$/c1
c0

Output:
1 for true
0 for false
Try it online!

Python 2.7, 102 92 bytes
For loop works better :/
s=`input()`
a,b,l=0,0,len(s)
for i in range(l/2):a=a+int(s[i]);b=b+int(s[l-i-1])
print a==b

Same idea, just use length - i to get other side.  It will never reach the center of an odd number.
Old code
s=input()
l=len(s)
def n(i):return 0if not i else int(i[0])+n(i[1:])
print n(s[:l/2])==n(s[l/2+l%2:])

Gets input
Saves length of input
Recursive func to get sum of string
Compare the first half sum to the second half sum
Trying to get it below 100, but its hard :/

PHP, 66 Bytes
for(;2*$i<$l=strlen($t=$argv[1]);)$s+=$t[$i++]-$t[$l-$i];echo+!$s;

-4 Bytes by @Titus Thank You

That $t[$i++]-$t[$l-$i] trick is great! It saves 4 bytes in my JS answer :-)

unnecessary parentheses around the $l assignment; always returns 1 for odd lengths with PHP < 7.

@Titus the result for php -r "for(;$i<($l=strlen($t=$argv[1]))/2;)$s+=$t[$i++]-$t[$l-$i];echo$s?0:1;" 110 is 0 under PHP 7. You are sure that your input is a string?

No it wasn´t. but you still don´t need the parentheses.

@Titus If a remove the parentheses $l=strlen($t=$argv[1])/2 the variable is the half value and I get a wrong result

Oops. You´re right. Use 2*$i<$l=strlen($t=$argv[1]) instead.

And echo+!$s; for the output. (-2)

C function, 74
l;i;t;f(char *n){l=strlen(n);for(t=i=0;i<l/2;)t+=n[i]-n[l-++i];return !t;}

Ideone.

You can't use strlen without including #include"string.h"\n, which adds 19 to your score.

@NoSeatbelts Yes you can - try out the Ideone link.  The compiler will most likely give you a bunch of warnings, but compile a working executable anyway (at least GCC and Clang do).  Which compiler are you using? There's even a code-golf tip about this.

No need for the space in char *n

remove spaces l;i;t;f(char*n){..return!t;} -2 bytes

Groovy - 74 69 bytes
Represented as a Groovy closure.  Please note that the parameter passed in (i) is a String, as with the Java version.
{i->e=i.size();k=0;s=0;for(;s<e;){k+=i.charAt(s++)-i.charAt(--e)};!k}

Hi, and welcome to the site! This is a nice first post, but assuming the input is stored in a predefined variable is not an allowed input method. I don't know much Groovy, but could you add something like i=input() or turn it into a function?

Rats, sorry - should be a bit better now; please do let me know.

JavaScript (ES5), 70 66 bytes

function g(n){for(a=b=0;(l=n.length)>b*2;)a+=n[b]-n[l-++b];return!a}

// tests:
var falses = ['10', '12', '110', '15421', '5234095123508321', '6240911314399072459493765661191058613491863144152352262897351988250431140546660035648795316740212454']
var i=falses.length;
while(i--) console.info(!g(falses[i]) ? 'ok' : 'not false: ' + falses[i])

var trues = ['1', '6', '11', '141', '1221', '23281453796004414', '523428121656666655655556655656502809745249552466339089702361716477983610754966885128041975406005088'];
i = trues.length;
while(i--) console.info(g(trues[i]) ? 'ok' : 'not true: ' + trues[i])

Nice answer! I count 67 bytes, not including the g (it doesn't count toward your byte count). You can also save a byte or two by switching to a for loop.

thx - very useful!!

Groovy (85 73 Bytes)
f={n->x=n.collect{[it,it]}.flatten().collate(n.size())*.sum();x[0]==x[1]}

.collect{[it,it]} - Dupe all elements into a 2D array.
.flatten() - Turn 2D array into 1D array.
.collate(n.size()) - Split new array in half.
*.sum() - Sum both sub-arrays.
x[0]==x[1] - Check for equality / return.

Jelly, 7 bytes
Dx2ŒH§E

Try it online!
Same algorithm as 05AB1E answer.

Python 3, 69 67 bytes
I'm quite proud of this one, since it's smaller than any other python answers in this thread :). I owe the idea of printing the equivalence of the two sums to tuukkaX's answer though, I don't think I would have thought of that myself.
*a,=map(int,input())
h=(len(a)+1)//2
print(sum(a[:h])==sum(a[-h:]))

Try it online!
The +1 on the second line is necessary to make my slices work properly for single digit inputs. I realised that even though it overslices, it does so on both sides so it still works.
On a list of len 1, slicing a[:0] gives an empty list but a[-0;] gives the whole list. Every 1 digit input became itself==0 so it was always false.
thanks to david for shaving off 2 bytes

h=(len(a)+1)//2 saves a couple of bytes

C# (Visual C# Interactive Compiler), 58 bytes
s=>s.Zip(s.Reverse(),(a,b)=>a-b).Take(s.Length/2).Sum()==0

Try it online!

C (gcc), 98 bytes
V=2;main(A,v)char**v;{char*a=*++v;while(a[1])a++;while(*v<a)V+=*(*v)++,A+=*a--;puts(A^V?"0":"1");}

There's a shorter submission for a C function, but mine compiles on its own and handles command line arguments.
Try it online!

92 bytes

flax, 7 bytes
EṠXFz˘D

Port of the 05AB1E answer. Ties with jelly. No online link as the latest commit is not on ATO.

Explanation
EṠXFz˘D

      D  ⊳ Digits
    z˘   ⊳ Zip with itself
   F     ⊳ Flatten
  X      ⊳ Split into two
EṠ       ⊳ Are the sum of the two halves equal?

Scala, 77 bytes
Like Java, must take Strings.
I'm sure someone could find an improvement.
def f(s:String)=(for(i<-0 until s.length/2)yield s(i)-s(s.length-i-1)).sum==0
Can test online

JavaScript 95 88 bytes
i=>(s=(i,a,b)=>[...i.slice(a,b)].reduce((p,e)=>p-e,0))(i=i+"",0,m=i.length/2)==s(i,m+.5)

Explanation:
Convert input to a string, create a function that takes string segments and sums up all of the digits, and call that function for the left and right halves of the input.

Tcl, 156 bytes
proc R n {set l [string le $n];puts [expr [join [split [string ra $n 0 [expr $l/2-($l%2==0)]] {}] +]==[join [split [string ra $n [expr $l/2] $l+$l] {}] +]]}

Try it online!

Burlesque, 39 bytes
{iTg1!!}s9XXsa2./s1{q%9!{<-%9!}}M-)++sm

Try it online!
{
 iT   # Generate tails
 g1   # Get var 1
 !!   # Select from array
}s9   # Save as var 9
XX    # Split int to digits
sa    # Number of digits
2./   # /2
s1    # Save as 1
{
 q%9! # Eval 9 as function
 {
  <-  # Reverse
  %9! # Eval 9 as function
 }
}M-   # Eval each contained function on the digits
)++   # Map sum
sm    # Same

Thunno E, \$14\log_{256}(96)\approx\$ 11.52 bytes
eDZPiES2AP.Sze

Attempt This Online!
Port of Emigna's 05AB1E answer.
    # E flag converts to string
e   # Map:
DZP #  Pair with itself
i   #  Convert to integer
E   # End map
S   # Flatten
2AP # Split in half
.S  # Sum each
ze  # All equal?

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


text:
ASCII Odd/Even Cipher
We'll define the ASCII Odd/Even Cipher via the below pseudocode:
Define 'neighbor' as the characters adjacent to the current letter in the string

If the one of the neighbors is out of bounds of the string, treat it as \0 or null

Take an input string

For each letter in the string, do
  If the 0-based index of the current letter is even, then
    Use the binary-or of the ASCII codes of both its neighbors
  Else
    If the ASCII code of the current letter is odd, then
      Use the binary-or of itself plus the left neighbor
    Else
      Use the binary-or of itself plus the right neighbor
  In all cases,
    Convert the result back to ASCII and return it
  If this would result in a code point 127 or greater to be converted, then
    Instead return a space

Join the results of the For loop back into one string and output it

For example, for input Hello, the output is emmol, since

The H turns to \0 | 'e' which is e
The e turns to 'e' | 'l', or 101 | 108, which is 109 or m
The first l also turns to 101 | 108 or m
The second l turns to 108 | 111, which is 111 or o
The o turns to 108 | \0, or l

Input

A sentence composed solely of printable ASCII characters, in any suitable format.
The sentence may have periods, spaces, and other punctuation, but will only ever be one line.
The sentence will be at least three characters in length.

Output

The resulting cipher, based on the rules described above, returned as a string or output.

The Rules

Either a full program or a function are acceptable.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Examples
Input on one line, output on the following. Blank lines separate examples.
Hello
emmol

Hello, World!
emmol, ww~ved

PPCG
PSWG

Programming Puzzles and Code Golf
r wogsmmoonpuu ~ meannncoooeggonl

abcdefghijklmnopqrstuvwxyz
bcfefgnijknmno~qrsvuvw~yzz

!abcdefghijklmnopqrstuvwxyz
aaccgeggoikkomoo qsswuww yy

Test 123 with odd characters. R@*SKA0z8d862
euutu133www|todddchizsscguwssr`jS{SK{z~|v66

Is this really a cipher? Doesn't seem to be a way to decipher it.

Given that the o changes to l in the first example, I'm pretty sure your specs ensure that the first o does not change to l in the second example. It should change to 'l' | ',', whatever that is, right?

@pipe Yeah. Not really a "cipher" but, not really sure what to call it. It's not really a hash, either. Of the tags we've got, "cipher" seemed closest, so that's what I went with.

@GregMartin Yes, it goes to 'l' | ',', which is 108 | 44 --> 1101111 | 0101100, which becomes 108, which is l. The , happens to line up with the l, so there's no change when the binary-or takes place.

Oh, it's really the binary-OR ... I was thinking the binary-XOR. Thank you for the clarification. On the other hand, this speaks even more to pipe's observation that this "cipher"can't really be deciphered, as far as I can tell.

Jelly, 33 31 bytes
2ịḂị|2\
|ṚḢ,Ç
O0,0jṡ3µÇ€⁸JḂ¤ị"Ọ

A straight-forward approach that can surely be made shorter.
Try it online!

Perl, 63 62 bytes
Includes +4 for -lp
Give input on STDIN
oddeven.pl:
#!/usr/bin/perl -lp
s%.%(--$|?$n|$':$&|(ord$&&1?$n:$'))&($n=$&,~v0)%eg;y;\x7f-\xff; ;

This works as shown, but to get the claimed score this must be put in a file without final ; and newline and the \xhh escapes must be replaced by their literal values. You can do this by putting the code above in the file and running:
perl -0pi -e 's/\\x(..)/chr hex $1/eg;s/;\n$//' oddeven.pl

Python 2, 138 131 bytes
s="\0%s\0"%input();r=''
for i in range(len(s)-2):L,M,R=map(ord,s[i:i+3]);a=i%2and[R,L][M%2]|M or L|R;r+=chr(a*(a<127)or 32)
print r

Try it online (contains all test cases)
Less golfed:
def f(s):
    s="\0%s\0"%s
    r=''
    for i in range(1,len(s)-1):
        if i%2: # even (parity is changed by adding \x00 to the front)
            a=ord(s[i-1]) | ord(s[i+1])
        else:   # odd
            a=ord(s[i])
            if a%2: # odd
                a|=ord(s[i-1])
            else:   # even
                a|=ord(s[i+1])
        r+=chr(a if a<127 else 32)
    print r

Try it online (ungolfed)
I add \x00 to both sides of the string so that I don't have to worry about that during bitwise or-ing. I loop along the string's original characters, doing bitwise operations and adding them to the result, following the rules for parity.

Dang, I'm jealous of that |= ... equivalent in PowerShell would be $a=$a-bor$b

@TimmyD I didn't actually end up using it, but yeah. It's nice. If only Python had a?b:c like JS.

You can replace
if a%2: # odd
a|=ord(s[i-1])
else:   # even
a|=ord(s[i+1])
with
a|=ord(s[i+1-2*(a%2)])

@NoSeatbelts That's my ungolfed code, which will be left as-is for readability purposes. The golfed submission is the top program.

Mathematica, 152 bytes
FromCharacterCode[BitOr@@Which[OddQ@Max@#2,#~Drop~{2},OddQ@#[[2]],Most@#,True,Rest@#]/._?(#>126&)->32&~MapIndexed~Partition[ToCharacterCode@#,3,1,2,0]]&

Explanation
ToCharacterCode@#

Converts string to ASCII codes
Partition[...,3,1,2,0]

Partitions the ASCII codes to length 3, offset 1 partitions, with padded 0s.
...~MapIndexed~...

Applys a function for each partition.
Which[...]

If...else if... else in Mathematica.
OddQ@Max@#2

Checks whether the index (#2) is odd. (Max is for flattening); since Mathematica index starts at 1, I used OddQ here, not EvenQ
Drop[#,{2}]

Takes the ASCII codes of the left and right neighbors.
OddQ@#[[2]]

Checks whether the ASCII code of the corresponding character is odd.
Most@#

Takes the ASCII codes of the character and the left neighbor.
Rest@#

Takes the ASCII codes of the character and the right neighbor.
BitOr

Applys or-operation.
/._?(#>126&)->32

Replaces all numbers greater than 126 with 32 (space).
FromCharacterCode

Converts ASCII code back to characters and join them.

Welcome to PPCG! Could you add a bit of explanation for people (like me) who aren't well versed in Mathematica? Also be sure to check out Tips for golfing in Mathematica for some suggestions. Enjoy your stay!

A few improvements: Accepting and returning a list of characters instead of an actual string object is completely fine and saves a lot on those From/ToCharacterCode functions. Then it looks like your Drop can use infix notation: #~Drop~{2}. And it seems that you're applying BitOr to every possible output of the Which so why not apply it afterwards and only once?

Ruby 133 128 108 106 bytes
Jordan helped me save 20 bytes and cia_rana helped me save 2 bytes :)
->s{p s[-i=-1]+s.bytes.each_cons(3).map{|x,y,z|i+=1;a=i%2>0?x|z :y%2>0?y|x :y|z;a>126?' ':a.chr}*""+s[-2]}

s is taken as the input string.
Example output with s="Test 123 with odd characters. R@*SKA0z8d862":
"euutu133www|todddchizsscguwssr`jS{SK{z~|v66"

Explanation
The above code is very unreadable so here is an explanation. The code is kind of hacky, I'm quit new to ruby so I bet there is a shorter way to do this :)
b=s[1] # for the first character we always use the right neighbour
       # because `\0 | x` will always return x any way. 0 is the
       # left neighbour and x is the right neigbour
s.bytes.each_cons(3).with_index{|c,i| # oh boy, first we convert the string to ascii with each_byte
                                          # we then traverse the resulting array with three elements at
                                          # a time (so for example if s equals "Hello", c will be equal
                                          # to [72, 101, 108])
  if (i+1) % 2 < 1 # if the middle letter (which is considered our current letter) is even
    a = c[0] | c[2] # we use the result of binary-or of its neighbours
  else
    if c[1] % 2 > 0 # if the code of the current letter is odd
      a = c[1] | c[0] # we use the result of binary-or of itself and its left neighbour
    else
      a = c[1] | c[2] # we use the result of binary-or of itself and its right neighbour
    end
  end
  if a>126
    b<<' ' # if the result we use is greater or equal to 127 we use a space
  else
    b<<a.chr # convert the a ascii value back to a character
  end
}
p b+s[-2] # same as the first comment but now we know that x | \0 will always be x
          # this time x is the last characters left neighbour

I'm fairly certain the output needs to be on one line, since the input is also.

@mbomb007 bummer, then I have to use print instead of p :p

@TimmyD oh, so I can't print it to the output at different times?

@TimmyD ok, so the above is allowed? It now prints everything on one line.

@Linus Yeah, that's fine. Welcome to PPCG, by the way!

You can use bytes instead of each_byte here, and you'll save bytes by initializing i=0 before enumerating and incrementing with i+=1 inside the block instead of using with_index.

@Jordan do you mean like this?

Yep, but you need to take an argument (s). Also, you can use semicolons or newlines instead of both ands. Also: i%2>0 instead of (i+1)%2<1, and destructure c into the separate variables (e.g. each_cons(3){|x,y,z|...) so you can use e.g. x instead of c[0].

@Jordan thanks, for the help. For some reason when I substitute the c variable for x, y, z I get a syntax error. Here is what it looks like now.

Ruby ternaries get hairy without whitespace. Try this: a=i%2>0?x|z :y%2>0?y|x :y|z.

@Jordan great, that last tip was really useful. I updated my answer.

Looks good! Welcome to PPCG!

You can write as shown below: ->s{p s[-i=-1]+s.bytes.each_cons(3).map{|x,y,z|i+=1;a=i%2>0?x|z :y%2>0?y|x :y|z;a>126?' ':a.chr}*""+s[-2]}

@cia_rana thanks, that\s really clever, I updated my answer :)

C - 101 bytes
i,k;f(char*p){for(i=0;*p;++p,++i)putchar((k=i&1?*p&1?*p|p[-1]:*p|p[1]:i?p[-1]|p[1]:p[1])<127?k:' ');}

We don't even have to check if it's the last item in the string because strings in C are null-terminated.
Explanation
Rather simple:
Use &1 to test for odd/evenness and ternary expressions to replace if/elses. Increment the char *p to reduce the number of brackets required.

Nice answer -- welcome to PPCG!

J, 42 bytes
4:u:3({.OR{:)`((2|1&{){2:OR/\|.)\0,~0,3&u:

Uses the property that verbs in J can be applied in an alternating fashion using a gerund ` for certain adverbs such as infix \.
Usage
   f =: 4:u:3({.OR{:)`((2|1&{){2:OR/\|.)\0,~0,3&u:
   f 'Hello'
emmol
   f 'Hello, World!'
emmol,ww~ved
   f 'PPCG'
PSWG
   f 'Programming Puzzles and Code Golf'
rwogsmmoonpuu~meannncoooeggonl
   f 'abcdefghijklmnopqrstuvwxyz'
bcfefgnijknmno~qrsvuvw~yzz
   f '!abcdefghijklmnopqrstuvwxyz'
aaccgeggoikkomooqsswuwwyy
   f 'Test 123 with odd characters. R@*SKA0z8d862'
euutu133www|todddchizsscguwssr`jS{SK{z~|v66

Explanation
4:u:3({.OR{:)`((2|1&{){2:OR/\|.)\0,~0,3&u:  Input: string S
                                      3&u:  Convert each char to an ordinal
                                    0,      Prepend 0
                                 0,~        Append 0
    3                           \           For each slice of size 3
     (      )`                                For the first slice (even-index)
          {:                                    Get the tail
      {.                                        Get the head
        OR                                      Bitwise OR the head and tail
             `(                )              For the second slice (odd-index)
                             |.                 Reverse the slice
                       2:   \                   For each pair
                         OR/                      Reduce using bitwise OR
                  1&{                           Get the middle value of the slice
                2|                              Take it modulo 2
                      {                         Index into the bitwise OR pairs and select
                                              Repeat cyclically for the remaining slices
4:u:                                        Convert each ordinal back to a char and return

JavaScript (ES6), 125 118 114 bytes
Embarrassingly long, but charCodeAt and String.fromCharCode alone are 29 bytes. :-/
s=>[...s].map((_,i)=>String.fromCharCode((x=(C=i=>s.charCodeAt(i))((i-1)|1)|C(i+1-2*(C(i)&i&1)))>126?32:x)).join``

How it works
Each character at position i is translated with the following formula, which covers all rules at once:
C((i - 1) | 1) | C(i + 1 - 2 * (C(i) & i & 1))

where C(n) returns the ASCII code of the n-th character of the input string.
Demo

let f =

s=>[...s].map((_,i)=>String.fromCharCode((x=(C=i=>s.charCodeAt(i))((i-1)|1)|C(i+1-2*(C(i)&i&1)))>126?32:x)).join``

console.log(f("Hello"));
console.log(f("Hello, World!"));
console.log(f("PPCG"));
console.log(f("Programming Puzzles and Code Golf"));
console.log(f("abcdefghijklmnopqrstuvwxyz"));
console.log(f("!abcdefghijklmnopqrstuvwxyz"));
console.log(f("Test 123 with odd characters. R@*SKA0z8d862"));

PHP, 107 97 bytes
probably golfable.
for(;$i<strlen($s=$argv[1]);$i++)echo chr(ord($s[$i-1+$i%2])|ord($s[$i+1-2*($i&ord($s[$i])&1)]));

C#, 145 bytes
s=>{var r=s[1]+"";int i=1,l=s.Length,c;for(;i<l;i++){c=i>l-2?0:s[i+1];c=i%2<1?s[i-1]|c:s[i]|(s[i]%2>0?s[i-1]:c);r+=c>'~'?' ':(char)c;}return r;};

Full program with ungolfed method and test cases:
using System;

namespace ASCIIOddEvenCipher
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<string,string>f= s=>
            {
                var r = s[1] + "";
                int i = 1, l = s.Length, c;
                for(;i < l; i++)
                {
                    c = i>l-2 ? 0 : s[i+1];
                    c = i%2<1 ? s[i-1]|c : s[i]|(s[i]%2>0 ? s[i-1] : c);
                    r += c > '~' ? ' ' : (char)c;
                }
                return r;
            };

            //test cases:
            Console.WriteLine(f("Hello"));  //emmol
            Console.WriteLine(f("Hello, World!"));  //emmol, ww~ved
            Console.WriteLine(f("PPCG"));   //PSWG
            Console.WriteLine(f("Programming Puzzles and Code Golf"));  //r wogsmmoonpuu ~ meannncoooeggonl
            Console.WriteLine(f("abcdefghijklmnopqrstuvwxyz")); //bcfefgnijknmno~qrsvuvw~yzz
            Console.WriteLine(f("!abcdefghijklmnopqrstuvwxyz"));    //aaccgeggoikkomoo qsswuww yy
            Console.WriteLine(f("Test 123 with odd characters. R@*SKA0z8d862"));    //euutu133www|todddchizsscguwssr`jS{SK{z~|v66
        }
    }
}

This turned out to be longer than I thought...

source: Stack Exchange

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

sort: votes


text:
Prime counting function
Introduction
The Prime Counting Function, also known as the Pi function \$\pi(x)\$, returns the amount of primes less than or equal to x.
Challenge
Your program will take an integer x which you can assume to be positive, and output a single integer equal to the amount of primes less than or equal to x. This is a code-golf challenge, so the winner will be the program with the fewest bytes.
You may use any language of your choosing provided that it existed before this challenge went up, but if the language has a built-in prime-counting function or a primality checking function (such as Mathematica), that function cannot be used in your code.
Example Inputs
Input:
1
Output:
0
Input:
2
Output:
1
Input:
5
Output:
3
A000720 - OEIS

What about other prime-related functions? For example, "next prime" funciton

what about prime factorization functions?

Welcome to Programming Puzzles and Code Golf!

As Adnan said, welcome to PPCG! For future challenges, let me recommend the Sandbox where you can post a challenge to get meaningful feedback and critique before posting it to the main site.

I think this is what @TheBikingViking meant to link to: Related

The "no primality checking functions" kept me from posting this elegant Oasis solution: np+U

@mbomb007 Thanks, that was what I meant to link to. I've deleted my comment to prevent confusion.

Can I use isprime ?

@roslup isprime was explicitly banned.

05AB1E, 3 bytes
!fg

This assumes that factorization built-ins are allowed. Try it online!
How it works
!    Compute the factorial of the input.
 f   Determine its unique prime factors.
  g  Get the length of the resulting list.

That's really clever!

Damn, I'm getting rekt in my own language for the second time haha. +1

Why does this work?

@Oliver Because the factorial of n is divisible by all integers 1, ..., n (in particular, the primes p ≤ n), and by no other prime q > n since it cannot be expressed as a product of smaller numbers.

ÅP is a built-in for getting the list of all prime numbers $≤n$. Not that it saves any bytes, but…¯\(ツ)/¯

Very neat that builtin-using solutions, .Ø> and ÅPg, are the same length as this.

@OliverNi The prime factors of x! cannot include any prime factors > x, since it's only a multiple of numbers <= x. It includes all the prime factors <= x.

@OliverNi Consider 7! It's 5040. 5040 is, because it's a factorial, divisible by all primes lower than 7, including 7. The next prime above 7 is 11 - it's impossible for 5040 to be divisible by 11, because it wasn't derived by multiplying 11, or any multiple of 11 (which must all be > 11) into it.

Python 2, 45 bytes
f=lambda n,k=1,p=1:n/k and p%k+f(n,k+1,p*k*k)

Uses the Wilson's Theorem prime generator. The product p tracks (k-1)!^2, and p%k is 1 for primes and 0 for nonprimes.

Calculating the factorial from the bottom up is a great trick. +1

MATL, 11, 10, 8, 5 bytes
:pYFn

Try it online!
I wrote a version that had a really cool explanation of how MATL's matrices work:
:YF!s1=1
But it's no longer relevant. Check out the revision history if you want to see it.
New explanation:
:p      % Compute factorial(input)
  YF    % Get the exponenents of prime factorization
    n   % Get the length of the array

Three bytes saved thanks to Dennis's genius solution

It's shorter to use the function "exponents of prime factorization", because that one vectorizes: YF!s1=s

@LuisMendo That's a totally different approach, so feel free to go ahead and post it. (Although if you don't want to, I happily would)

Go ahead. I'll port that to Jelly to practice :-)

Perl, 33 bytes
Includes +1 for -p
Give the input number on STDIN
primecount.pl
#!/usr/bin/perl -p
$_=1x$_;$_=s%(?!(11+)\1+$)%%eg-2

Gives the wrong result for 0 but that's OK, the op asked for support for positive integers only.

MediaWiki templates with ParserFunctions, 220 + 19 = 239 bytes
{{#ifexpr:{{{2}}}+1={{{1}}}|0|{{#ifexpr:{{{3}}}={{{2}}}|{{P|{{{1}}}|{{#expr:{{{2}}}+1}}|2}}|{{#ifexpr:{{{2}}} mod {{{3}}}=0|{{#expr:1+{{P|{{{1}}}|{{#expr:{{{2}}}+1}}|2}}|{{P|{{{1}}}|{{{2}}}|{{#expr:{{{2}}}+1}}}}}}}}}}}}

To call the template:
{{{P|{{{n}}}|2|2}}}

Arranged in Lisp style:
{{#ifexpr:{{{2}}} + 1 = {{{1}}}|0|
    {{#ifexpr:{{{3}}} = {{{2}}} |
        {{P|{{{1}}}|{{#expr:{{{2}}} + 1}}|2}} |
            {{#ifexpr:{{{2}}} mod {{{3}}} = 0 |
                {{#expr:1 + {{P|{{{1}}}|{{#expr:{{{2}}} + 1}}|2}} |
                {{P|{{{1}}}|{{{2}}}|{{#expr:{{{2}}} + 1}}}}}}}}}}}}

Just a basic primality test from 2 to n. The numbers with three braces around them are the variables, where {{{1}}} is n, {{{2}}} is the number being tested, {{{3}}} is the factor to check.

Jelly, 8 5 bytes
3 bytes saved thanks to @Dennis!
RÆESL

Try it online!
Port of DJMcMayhem's MATL answer (former version) refined by Dennis.
R          Range of input argument
 ÆE        List of lists of exponents of prime-factor decomposition
   S       Vectorized sum. This right-pads inner lists with zeros
    L      Length of result

Correction: port of Luis Mendo's: DJMcMayhem's MATL answer. :P

You only need the maximal length of the results of ÆE, as each exponent corresponds to a different prime factor. RÆESL achieves just that. !ÆEL would be even shorter.

@Dennis Thanks! I've used the first suggestion. The second one is too different, and is your approach

Retina 0.8.2, 31 22 bytes
Byte count assumes ISO 8859-1 encoding.
.+
$*
(?!(..+)\1+$).\B

Try it online - Input much larger than 2800 either times out or runs out of memory.
References:
Martin's range generator
Martin's prime checker

Can be done in 22 bytes by replacing the last three lines with (?!(..+)\1+$).\B. Also makes it less inefficient (can handle inputs up to about 7000). (Also first line should really be .+.)

Jelly, 13 11 10 9 8 7 6 bytes
Using no built-in prime functions whatsoever
-1 byte thanks to @miles (use a table)
-1 byte thanks to @Dennis (convert from unary to count up the divisors)
ḍþḅ1ċ2

TryItOnline
Or see the first 100 terms of the series n=[1,100], also at TryItOnline
How?
ḍþḅ1ċ2 - Main link: n
 þ     - table or outer product, n implicitly becomes [1,2,3,...n]
ḍ      - divides
  ḅ1   - Convert from unary: number of numbers in [1,2,3,...,n] that divide x
                             (numbers greater than x do not divide x)
    ċ2 - count 2s: count the numbers in [1,2,3,...,n] with exactly 2 divisors
                   (only primes have 2 divisors: 1 and themselves)

You can get to 7 bytes %þ`¬Sċ2 using a table of remainders.

ḍþḅ1ċ2 saves a byte.

JavaScript (ES6), 45 43 bytes
f=(n,x=n)=>n>1&&(--x<2)+(n%x?f(n,x):f(n-1))

A modification of my 36 35 33-byte primality function (1 byte saved by @Neil, 2 by @Arnauld):
f=(n,x=n)=>n>1&--x<2||n%x&&f(n,x)

(I can't post this anywhere because Is this number a prime? only accepts full programs...)
Test snippet

f=(n,x=n)=>n>1&&(--x<2)+(n%x?f(n,x):f(n-1))
<input type="number" oninput="console.log('f('+this.value+') is '+f(this.value))" value=2>

Waw...it took me a while to understand. Nice job!

Sadly it doesn't apply to your answer but you can probably get away with one & in the middle of your primality function.

Jelly, 3 bytes
!Æv

Try it online!
How it works
!Æv  Main link. Argument: n

!    Compute the factorial of n.
 Æv  Count the number of distinct prime factors.

PowerShell v2+, 98 bytes
param($n)if($j='001'[$n]){}else{for($i=1;$i-lt$n){for(;'1'*++$i-match'^(?!(..+)\1+$)..'){$j++}}}$j

Caution: This is slow for large input.
Basically the unary-based lookup from Is this number a prime?, coupled with a for loop and a $j++ counter. A little additional logic on the front to account for edge cases input 1 and 2, due to how the fenceposting works in the for loops.

Jelly, 6 bytes
Ḷ!²%RS

This uses only basic arithmetic and Wilson's theorem. Try it online! or verify all test cases.
How it works
Ḷ!²%RS  Main link. Argument: n

Ḷ       Unlength; yield [0, ..., n - 1].
 !      Factorial; yield [0!, ..., (n - 1)!].
  ²     Square; yield [0!², ..., (n - 1)!²].
    R   Range; yield [1, ..., n].
   %    Modulus; yield [0!² % 1, ..., (n - 1)!² % n].
        By a corollary to Wilson's theorem, (k - 1)!² % k yields 1 if k is prime
        and 0 if k is 1 or composite.
     S  Sum; add the resulting Booleans.

05AB1E, 5 bytes
Assumes that prime factorization builtins are allowed.
Code:
LÒ1ùg

Explanation:
L      # Get the range [1, ..., input]
 Ò     # Prime factorize each with duplicates
  1ù   # Keep the elements with length 1
    g  # Get the length of the resulting array

Uses the CP-1252 encoding. Try it online!

ÅPg is what it'd be now, right?

C# 5.0 78 77
int F(int n){int z=n;if(n<2)return 0;for(;n%--z!=0;);return(2>z?1:0)+F(n-1);}

Ungolfed
int F(int n)
{
    var z = n;
    if (n < 2) return 0;
    for (; n % --z != 0;) ;
    return F(n - 1) + (2 > z ? 1 : 0);
}

@tfbninja yes you right, but I gave the function part only, which does not compile by it's own

@tfbninja Actually, it's not.

cool sounds good!

Regex (Perl / Java / PCRE), 32 bytes
((?=(\2?+x*?(?!(xx+)\3+$))xx)x)*

Try it online! - Perl
Try it online! - Java
Try it online! - PCRE
Takes its input in unary, as a string of x characters whose length represents the number. Returns its output as the length of the match.
        # tail = N = input value; no anchor needed, as every value returns a match
# Count the number of primes <= N, from the largest to the smallest prime.
(       # J = 0
    (?=
        # \2 starts at zero, and on each subsequent iteration, contains the difference
        # N-P-(J-1) where P is the previously found prime, and J is the running total of
        # our prime count.
        (
            \2?+           # Start from the previous value of \2, atomically so that it
                           # can't be backtracked and started again from zero if the
                           # following fails to match. This will make tail = P-1, where
                           # P is the previously found prime.
            x*?            # Advance as little as necessary to make the following match,
                           # and add this to \2, while subtracting it from tail.
            (?!(xx+)\3+$)  # Assert tail is not composite; note that this needs to be
                           # inside group \2 for it to work in PCRE1 and older versions of
                           # PCRE2, which atomicize groups that have nested backreferences
        )
        xx                 # Assert tail is prime by eliminating the false positives 0, 1
    )
    x   # J += 1; tail -= 1
)*      # Iterate zero or more times, until there are no more smaller primes
# Return J as our match

Regex (Pythonregex / Ruby), 41 39 bytes
((?=(?=(\3?))(\2x*?(?!(xx+)\4+$))xx)x)*

Try it online! - Python import regex
Try it online! - Ruby
This is a port of the Perl/Java/PCRE regex to flavors that have no support for nested backreferences. Python's built-in re module does not even support forward backreferences, so for Python this requires regex.
        # tail = N = input value; no anchor needed, as every value returns a match
# Count the number of primes <= N, from the largest to the smallest prime.
(       # J = 0
    (?=
        # \2 starts at zero, and on each subsequent iteration, contains the difference
        # N-P-(J-1) where P is the previously found prime, and J is the running total of
        # our prime count.
        (?=(\3?))          # \2 = \3 (or 0 if \3 is unset), to make up for the lack of
                           #      nested backreferences
        (
            \2             # Start from the previous value of \3 (as copied into \2).
                           # This will make tail = P-1, where P is the previously found
                           # prime.
            x*?            # Advance as little as necessary to make the following match,
                           # and add this to \3, while subtracting it from tail.
            (?!(xx+)\4+$)  # Assert tail is not composite; note that this needs to be
                           # inside group \3 for it to work in PCRE1 and older versions of
                           # PCRE2, which atomicize groups that have nested backreferences
        )
        xx                 # Assert tail is prime by eliminating the false positives 0, 1
    )
    x   # J += 1; tail -= 1
)*      # Iterate zero or more times, until there are no more smaller primes
# Return J as our match

Regex (.NET), 35 bytes
((?=((?>\2?)x*?(?!(xx+)\3+$))xx)x)*

Try it online!
This is a direct port of the Perl/Java/PCRE regex.
Regex (.NET), 35 bytes
^(?=(x*?(?!(xx+)\2+$)x)*x)(?<-1>x)*

Try it online!
This uses the .NET feature of balanced groups to do the counting. It does not return a value for zero, but doing so only requires +1 byte (36 bytes):
^(?=(x*?(?!(xx+)\2+$)x)*x|)(?<-1>x)*

Try it online!
^                      # tail = N = input number
(?=
    (
        x*?            # Advance as little as necessary to make the following match
        (?!(xx+)\3+$)  # Assert tail is not composite
        x              # Eliminate the false primality positive of 0, and advance forward
                       # so that the next prime can be found (if we didn't do this, the
                       # regex engine would exit the loop due to a zero-width match)
    )*                 # Every time this loop matches an iteration, the capture group 1
                       # match is pushed onto the stack. This (balanced groups) is how we
                       # count the number of primes.
    x                  # Eliminate the false primality positive of 1
|                      # Allow us to return a value of 0 for N=0
)
(?<-1>x)*              # Pop all of the group 2 captures off the stack, doing head += 1
                       # for each one. This gives us our return value match.

I strongly suspect this function is impossible to implement in ECMAScript regex, even with the addition of (?*) or (?<=) / (?<!). There doesn't seem to be room to multiplex the count and the current prime into a single tail variable, but I don't know if this can be proved.
Only one variable can be modified within a loop, such that must decrease by at least 1 on every step – and only \$O(n)\$ space is available; no variable may contain a value larger than \$n\$, and the language has no concept of arrays (although it is possible to take them as immutable input), only scalar variables (i.e. capture groups and the cursor position).
So it would seem that calculating this function would require \$O({n^2\over log(n)})\$ scratch space, to multiplex the iteration count and current prime into a single number. While multiple loops in a row would be able to get closer to \$\pi(n)\$ than a single loop, the number of such loops could only be a constant; it seems that it would need to be able to grow with \$n\$ to be able to actually asymptotically calculate \$\pi(n)\$. And a nested loop would still have to distill all the information gained by its innermost loop into a single number \$\le n\$.
But these things are just indications and vague evidence, not a proof. I have set a bounty regarding this open question.

C#, 157 bytes
n=>{int c=0,i=1,j;bool f;for(;i<=n;i++){if(i==1);else if(i<=3)c++;else if(i%2==0|i%3==0);else{j=5;f=1>0;while(j*j<=i)if(i%j++==0)f=1<0;c+=f?1:0;}}return c;};

Full program with test cases:
using System;

class a
{
    static void Main()
    {
        Func<int, int> s = n =>
            {
                int c = 0, i = 1, j;
                bool f;
                for (; i <= n; i++)
                {
                    if (i == 1) ;
                    else if (i <= 3) c++;
                    else if (i % 2 == 0 | i % 3 == 0) ;
                    else
                    {
                        j = 5;
                        f = 1 > 0;
                        while (j * j <= i)
                            if (i % j++ == 0)
                                f = 1 < 0;
                        c += f ? 1 : 0;
                    }
                }
                return c;
            };

        Console.WriteLine("1 -> 0 : " + (s(1) == 0 ? "OK" : "FAIL"));
        Console.WriteLine("2 -> 1 : " + (s(2) == 1 ? "OK" : "FAIL"));
        Console.WriteLine("5 -> 3 : " + (s(5) == 3 ? "OK" : "FAIL"));
        Console.WriteLine("10 -> 4 : " + (s(10) == 4 ? "OK" : "FAIL"));
        Console.WriteLine("100 -> 25 : " + (s(100) == 25 ? "OK" : "FAIL"));
        Console.WriteLine("1,000 -> 168 : " + (s(1000) == 168 ? "OK" : "FAIL"));
        Console.WriteLine("10,000 -> 1,229 : " + (s(10000) == 1229 ? "OK" : "FAIL"));
        Console.WriteLine("100,000 -> 9,592 : " + (s(100000) == 9592 ? "OK" : "FAIL"));
        Console.WriteLine("1,000,000 -> 78,498 : " + (s(1000000) == 78498 ? "OK" : "FAIL"));
    }
}

Starts to take awhile once you go above 1 million.

Jelly, 3 bytes
ÆRL

Jelly has a built-in prime counting function, ÆC and a prime checking function, ÆP, this instead uses a built-in prime generating function, ÆR and takes the length L.
I guess this is about as borderline as using prime factorisation built-ins, which would also take 3 bytes with !Æv (! factorial, Æv count prime factors)

Matlab, 60 bytes
Continuing my attachment to one-line Matlab functions. Without using a factorisation built-in:
f=@(x) nnz(arrayfun(@(x) x-2==nnz(mod(x,[1:1:x])),[1:1:x]));

Given that a prime y has only two factors in [1,y]: we count the numbers in the range [1,x] which have only two factors.
Using factorisation allows for significant shortening (down to 46 bytes).
g=@(x) size(unique(factor(factorial(x))),2);

Conclusion: Need to look into them golfing languages :D

MATL, 9 bytes
This avoids prime-factor decomposition. Its complexity is O(n²).
:t!\~s2=s

Try it online!
:     % Range [1 2 ... n] (row vector)
t!    % Duplicate and transpose into a column vector
\     % Modulo with broadcast. Gives matrix in which entry (i,j) is i modulo j, with
      % i, j in [1 2 ... n]. A value 0 in entry (i,j) means i is divisible by j
~     % Negate. Now 1 means i is divisible by j
s     % Sum of each column. Gives row vector with the number of divisors of each j
2=    % Compare each entry with 2. A true result corresponds to a prime
s     % Sum

PHP, 96 92 bytes
for($j=$argv[1]-1;$j>0;$j--){$p=1;for($i=2;$i<$j;$i++)if(is_int($j/$i))$p=0;$t+=$p;}echo $t;

Saved 4 bytes thanks to Roman Gräf
Test online
Ungolfed testing code:
$argv[1] = 5;

for($j=$argv[1]-1;$j>0;$j--) {
    $p=1;
    for($i=2;$i<$j;$i++) {
        if(is_int($j/$i)) {
            $p=0;
        }
    }
    $t+=$p;
}
echo $t;

Test online

Why do you use isInt(...)?1:0 and not just isInt(...)

@RomanGräf Thanks, you are right. I left the ternary after a lot of code semplification, and that was so obvious that I couldn't see it...

Actually, 10 bytes
This was the shortest solution I found that didn't run into interpreter bugs on TIO. Golfing suggestions welcome. Try it online!
;╗r`P╜>`░l

Ungolfing
         Implicit input n.
;╗       Duplicate n and save a copy of n to register 0.
r        Push range [0..(n-1)].
`...`░   Push values of the range where the following function returns a truthy value.
  P        Push the a-th prime
  ╜        Push n from register 0.
  >        Check if n > the a-th prime.
l        Push len(the_resulting_list).
         Implicit return.

Pyke, 8 6 bytes
SmPs}l

Try it here!
Thanks to Maltysen for new algorithm
SmP    -    map(factorise, input)
   s   -   sum(^)
    }  -  uniquify(^)
     l - len(^)

Pyth - 7 6 bytes
Since others are using prime factorization functions...
l{sPMS

Test Suite.

Bash + coreutils, 30
seq $1|factor|egrep -c :.\\S+$

Ideone.

Bash + coreutils + BSD-games package, 22
primes 1 $[$1+1]|wc -l

This shorter answer requires that you have the bsdgames package installed: sudo apt install bsdgames.

Java 8, 95 84 bytes
z->{int c=0,n=2,i,x;for(;n<=z;c+=x>1?1:0)for(x=n++,i=2;i<x;x=x%i++<1?0:x);return c;}

Explanation:
Try it online.
z->{                // Method with integer parameter and integer return-type
  int c=0,          //  Start the counter at 0
      n=2,          //  Starting prime is 2
      i,x;          //  Two other temp integers
  for(;n<=z;        //  Loop (1) as long as `n` is smaller than or equal to the input `z`
       c+=x>1?1:0)  //    and increase the counter if we've came across a prime
                    //    (if `x` is larger than 0, it means the current `n` is a prime)
     for(x=n++,i=2;i<x;x=x%i++<1?0:x);
                    //   Determine if the next integer in line is a prime by setting `x`
                    //   (and increase `n` by 1 afterwards)
                    //  End of loop (1) (implicit / single-line body)
  return c;         //  Return the resulting counter
}                   // End of method

APL (Dyalog Unicode), 13 bytesSBCS
2+.=0+.=⍳∘.|⍳

Try it online!
⍳ ɩndices 1…N
 ⧽ ∘.| remainder-table (using those two as axes)
⍳ ɩndices 1…N
0+.= the sum of the elements equal to zero (i.e. how many dividers does each have)
2+.= the sum of the elements equal to two (i.e. how many primes are there)

Another approach    {⍴(⊢~∘.×⍨)1↓⍳⍵}

@AndrewOgden Ooh, that actually comes out shorter: (≢⊢~∘.×⍨)1↓⍳ ― Do you want to post that, it being a completely different approach?

I would, but it's not my algorithm. https://youtu.be/Gsj_7tFtODk?t=600

@AndrewOgden I know. I came up with it in '97 :-) Go ahead and post!

Lol, you're a legend.

APL (Dyalog Unicode), 12 bytes
(≢⊢~∘.×⍨)1↓⍳
 ≢ ⍝ tally
  ⊢~ ⍝ index values not in matrix of composite numbers
    ∘.×⍨ ⍝ outer product of positive integers with themselves
        1↓⍳ ⍝ range from 1–n less the first element

h/t @adám
Try it online!

C (clang), 49 bytes
p(n,i){for(i=n;--i&&n%i;);return--n?p(n)+!--i:0;}

Assumes n is positive.
Try it online!

Thunno, \$ 4 \log_{256}(96) \approx \$ 3.29 bytes
FAFL

Attempt This Online!
Port of Dennis's 05AB1E answer.
Explanation
F       # Push the factorial of the input
 AF     # Get the unique prime factors
   L    # Push the length of the list

JavaScript (ES6), 50+2 46+2 43 bytes
Saved 3 5 bytes thanks to Neil:
f=n=>n&&eval(`for(z=n;n%--z;);1==z`)+f(n-1)

eval can access the n parameter.
The eval(...) checks if n is prime.

Previous solutions:
Byte count should be +2 because I forgot to name the function f= (needed for recursion)
46+2 bytes (Saved 3 bytes thanks to ETHproductions):
n=>n&&eval(`for(z=n=${n};n%--z;);1==z`)+f(n-1)

50+2 bytes:
n=>n&&eval(`for(z=${n};${n}%--z&&z;);1==z`)+f(n-1)

At least on my browser, eval can access the n parameter to your function (which you forgot to name, costing you 2 bytes; it's good to know that I'm not the only one who makes that mistake) which saves you 5 bytes.

@Neil I didn't know for eval. Tested with firefox, chrome and edge it worked for me. The explanation is eval() parses in statement context. Two examples: a=12;f=b=>eval('a + 5');f(8) displays 17 and a=12;f=a=>eval('a + 5');f(8) displays 13.

Java 7,102 bytes
Brute force
int f(int n){int i=2,j=2,c=1,t=0;for(;i<=n;j=2,c+=t==1?1:0,i++)for(;j<i;t=i%j++==0?j=i+1:1);return c;}

Ungolfed
int f(int n){
int i=2,j=2,c=1,t=0;
for(;i<=n;j=2,c+=t==1?1:0,i++)
    for(;j<i;)
        t=i%j++==0?j=i+1:1;
    return c;
 }

This is currently giving an incorrect result for input 1. It currently returns 1 instead of 0. You can fix this by either changing return c; to return n<2?0:c; or changing ,c=1, to ,c=n<2?0:1,.

q 35 bytes
{sum 1=sum'[0=2_' a mod\: a:til x]}

Actually, 10 bytes
If my first Actually answer is disallowed for using a prime-generating function, here is a backup answer using Wilson's theorem. Golfing suggestions welcome. Try it online!
R`;D!²%`MΣ

Try it online
         Implicit input n.
R        Push range [1..n]
`...`M   Map the following function over the range. Variable k.
  ;        Duplicate k.
  D        Decrement one of the copies of k.
  !²       Push ((k-1)!)².
  %        Push ((k-1)!)² % k. This returns 1 if k is prime, else 0.
Σ        Sums the result of the map, adding all the 1s that represent primes,
          giving the total number of primes less than n.
         Implicit return.

Racket 60 bytes
(require math)(λ(n)(length(filter prime?(range 1(+ 1 n)))))

Testing:
(require math)
(define f
    (λ(n) (length (filter prime? (range 1 (+ 1 n)))))
)

(f 1)
(f 2)
(f 3)
(f 5)

Output:
0
1
2
3

If (require math) is required for your program to work, you need to include it in your byte count.

PARI/GP, 15 bytes
n->#factor(n!)~

Take the factorial and count its unique prime factors.

Actually, 3 bytes
This uses a prime factorization function, which may or may not be allowed after the OP clarifies. Golfing suggestions welcome. Try it online!
!yl

Ungolfing
     Implicit input n.
!    Push n factorial.
 y   Push a list of all of the positive prime factors of n! (every prime < n)
  l  Take the length of that list of primes.
     Implicit return.

APL NARS, 150 bytes
∇r←g n;h;i;k
i←0⋄h←1+⍳n-1⋄→B
A:k←i⊃h⋄h←k∪(0≠k∣h)/h
B:→A×⍳(⍴h)≥i+←1
r←⍴h
∇

this would be the "Crivello di Eratostene" or something as that.
If h=2..n
In the first  iteration of the loop eliminate each multiple of 2 in h except 2
in the second iteration of the loop eliminate each multiple of 3 in h except 3
...
return the number of final element of h.(in h primes return ⍴h)
  g¨1 2 5
0  1  3
  g 20000
2262

As note negative for the question: There would be a range limit for the arg of the function; something as 1..20000 and each answer would indicate the range the argument has to be for to be safe to pass to the function (without one seg fault in the code, without one memory insufficient for the program, without one incorrect value return as result )

Pyth, 6 bytes
l{P.!Q

Explanation follows:
   .!Q Factorial of input
  P    List primes of factorial with multiplicity
 {     Remove duplicates formed by said multiplicity
l      Length of deduplicated list

Pyt, 3 bytes
řṗƩ

Explanation:
ř         Push [1,2,...,input]
 ṗ        Elementwise isPrime(k)
  Ʃ       Sum of array (autoconverts booleans to 0/1)

Try it online!

So one can use isprime right?

Perl 6, 31 bytes
{+grep {$_%%none 2..^$_},2..$_}

Try it online!

(pure) BASH, 138 bytes
Look, Mom!
No preloaded prime tables, no prime related builtins, not even a division or plultimication!
a=2
l=0
while((a<=$1));do if((b[a]))
then((c=b[a]));else((c=a,l++));fi;((d=a+c))
while((b[d]));do((d+=c));done
((b[d]=c,a++));done;echo $l

Eating the pudding:
$ for i in 1 2 3 11033 ; do bash fsoe-primecounter-in-bash $i ; done
0
1
2
1337

Ok, probably looping while looking at candidates modulo all possible divisors would have been shorter in "pure BASH" too but we've seen those loops at least 1001 times now.
This solution builds its own prime table on the fly and so is bearably fast even in "pure BASH".

Python 3, 40 bytes
f=lambda n:1if n<1else(2**n%n==2)+f(n-1)

An odd integer k is prime if an only if 2**(k-1) is congruent to 1 mod k. Thus, we just check for this condition and add 1 for the case of k=2.

2**n % n==2 is not enough as primaly test

@RosLuP That is why the base case of n==0 should add 1 (to account for the n=2 case).

2**n % n==2 is not enough in general... Exist many (infinite in what I would remember) numbers where 2^n%n=2 that are not primes

For example 341=11*31 but ( 2^341) mod 341==2

@RosLuP: Ah ok yes, I looked it up. These numbers are called Fermat Psuedoprimes but they appear to be quite rare :P

Add++, 17 bytes
L,RB*f0b]@bLA1=!*

Try it online!

Kotlin, 85 bytes
{n:Int->var r=0
for(i in 2..n){var t=1
for(p in 2..i/2)if(i%p==0){t--
break}
r+=t}
r}

Try it online!
Try lambda for first time as saved 16 bytes.
Kotlin, 101 bytes
fun c(n:Int):Int{var r=0
for(i in 2..n){var t=1
for(p in 2..i/2)if(i%p==0){t--
break}
r+=t}
return r}

Try it online!

Haskell, 46 42 bytes
p n=sum[mod(product[1..i-1]^2)i|i<-[1..n]]

Try it online!

Python 3, 197 165 bytes
Removed the need for the import math by checking every divisor of i besides i itself, though mathematically only checking up to the square root is required.
def c(x):
    p=0
    for i in range(2,x+1):
        P=1
        for d in range(1,i):
            if i%d==0 and d!=1:
                P=0
        p+=1*P
    return p

Original:
import math
def c(x):
    p=0
    for i in range(2,x+1):
        P=1
        for d in range(1,round(math.sqrt(i))+1):
            if i%d==0 and d!=1:
                P=0
        p+=1*P
    return p

Welcome to Code Golf! You can golf this quite a bit by removing some whitespace, and I think you're allowed to use a lambda instead of a function if that'd be shorter.

Vyxal l, 2 bytes
¡Ǐ

Try it Online! - test cases only
This is the same as the 3 byte answer below except the length is taken by the l flag rather than an L element.
Vyxal, 3 bytes
¡ǏL

Try it Online!
¡  # Factorial
Ǐ  # Prime factorization - list of distinct prime factors
L  # Length of that list

Direct port of Dennis's 05AB1E solution, which is the accepted answer, so one would infer that it meets the challenge's specifications.
The element † could be considered a "prime-counting function", even though it counts the distinct prime factors of the input, not the primes less than or equal to the input. The solution using that built-in is 2 bytes:
¡†

Try it Online!
¡  # Factorial
†  # Number of distinct prime factors

Vyxal, 9 bytes
ɾ⟑‹¡²$%;∑

Try it Online!
With no factorization built-ins, instead using Wilson's theorem:
ɾ  # Inclusive One Range (from 1 to input)
⟑  # Apply lambda to each individual list item:
‹  # Subtract 1
¡  # Factorial
²  # Square
$  # Swap
%  # Modulo - this will be (n-1)!² % n
;  # Close lambda
∑  # Sum

With the r flag this is 8 bytes: Try it Online!
With the rs flags this is 6 bytes: Try it Online!

Python 2, 55 bytes
n=input()
s=p=i=1
while i<n:p*=i*i;i+=1;s+=p%i
print~-s

Try it online!
A programification of the below. The Python 3 equivalent is 62 bytes.
Note that although xnor's recursive answer outgolfs this at 45 bytes, it cannot handle an input of 999 or greater, due to Python's recursion limit: Try it online! - this limit can be increased, though: Try it online!
This 55 byte solution can go well beyond that. For example, all inputs up to 3000: Try it online!
Python 3.8+, 57 54 bytes
lambda n,p=1:sum([(p:=p*i*i)%-~i for i in range(1,n)])

Try it online! / Attempt This Online!
A lambdafication of the below, taking advantage of the := operator.
Although xnor's recursive answer outgolfs this at 46 bytes when ported to Python 3, it still can't handle an input of 999 or greater: Try it online! - this limit can be increased: Attempt This Online!
Python, 59 bytes
def P(n):
 s=p=i=1
 while i<n:p*=i*i;i+=1;s+=p%i
 return~-s

Try it online! - Python 2
Try it online! - Python 3
Based on miles's answer to "Is it a super-prime?".
This exploits Wilson's theorem and Python's arbitrary precision integers to count primes. At each iteration of the loop, with \$i\in[2,n]\$, it calculates \${(i-1)^2}!\pmod i\$. This \$\equiv 1\$ when \$i\$ is prime and \$\equiv 0\$ otherwise. The squaring is done to compensate for the fact that \$4\$ is the only exception, with \$(4-1)!\equiv 2\pmod 4\$, but \$(4-1)^2!\equiv 0\pmod 4\$. Note that squaring also changes the modulus from \$-1\$ to \$1\$ for prime \$i\$.
If not for the exception at i=4, we could have done
while i<n:p*=i;i+=1;s+=-p%i

For 1 byte less, because Python returns a positive result when taking a negative number modulo a positive number.

Stax, 4 bytes
Ü:÷/

Run and debug it
Same approach as many other answers. This is a packed stax program which unpacks to the following 5 bytes:
|F:F%

Run and debug it
Explanation
|F    # factorial of input
  :F  # distinct prime factors
    % # length

Japt, 6 bytes
Êk â Ê

Try it
Êk â Ê     :Implicit input of integer
Ê          :Factorial
 k         :Prime factors
   â       :Deduplicate
     Ê     :Length

Thunno 2 L, 2 bytes
wƑ

Try it online!
Port of Dennis's 05AB1E answer.
Explanation
wƑ  # Implicit input
w   # Factorial of input
 Ƒ  # Unique prime factors
    # Implicit output of length

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/