Piecewise-constant function with infinitely many pieces

That $F$ should really be something like $F_n$, defining a family of functions and then your total $F$ would really be the union of the $\{F_n\}$ over the domains where they are non-zero.

Then unless I am much mistaken each of those domains will have length $2$ and so we can define your family of functions as you had above and then have a dispatcher function to the appropriate function be your union function, using Quotient

So in total it will look like:

fxn[x_, n_] :=
  Piecewise[
   {
    {x - n, 2 n <= x <= 2 n + 1},
    {n + 1, 2 n + 1 <= x <= 2 n + 2}
    }
   ];
fxn[x_] :=
 fxn[x, Quotient[x, 2]]

And we'll confirm that I have this right:

With[{maxN = 10},
 {
  Plot[
   Evaluate@Table[fxn[x, n], {n , 0, maxN}], {x, 0, 2*maxN + 2}],
  Plot[fxn[x], {x, 0, 2*maxN + 2}]
  }
 ]

funion


"... I need it only as a function of x"

ClearAll[f]
f[x_] := Min[x - Quotient[x, 2], 1 + Quotient[x, 2]]

Plot[f[x], {x, 0, 10}]

enter image description here

Plot[f[x], {x, -5, 10}]

enter image description here

Plot[f[x], {x, 0, 50}]

enter image description here


One more way is as follows.

f[x_] := Sum[ Piecewise[{{x - n, 2 n <= x <= 2 n + 1}, {n + 1, 
2 n + 1 <= x <= 2 n + 2}}], {n, -Infinity, Infinity}];
Plot[f[x],  {x, -4, 5}]