fork download
  1. h=2:4;@(x)h.*ceil((x+1)./h)
  2. f = ans; [f(1); f(4); f(43); f(123); f(420); f(31415); f(1081177)]
  3.  
  4. @(x)x-rem(x,2:4)+(2:4)
  5. f = ans; [f(1); f(4); f(43); f(123); f(420); f(31415); f(1081177)]
  6.  
  7. h=2:4;@(x)x+h-rem(x,h)
  8. f = ans; [f(1); f(4); f(43); f(123); f(420); f(31415); f(1081177)]
  9.  
  10. @(x)x-rem(x,h=2:4)+h
  11. f = ans; [f(1); f(4); f(43); f(123); f(420); f(31415); f(1081177)]
Success #stdin #stdout 0.49s 121792KB
stdin
Standard input is empty
stdout
ans =

@(x) h .* ceil ((x + 1) ./ h)

ans =

         2         3         4
         6         6         8
        44        45        44
       124       126       124
       422       423       424
     31416     31416     31416
   1081178   1081179   1081180

ans =

@(x) x - rem (x, 2:4) + (2:4)

ans =

         2         3         4
         6         6         8
        44        45        44
       124       126       124
       422       423       424
     31416     31416     31416
   1081178   1081179   1081180

ans =

@(x) x + h - rem (x, h)

ans =

         2         3         4
         6         6         8
        44        45        44
       124       126       124
       422       423       424
     31416     31416     31416
   1081178   1081179   1081180

ans =

@(x) x - rem (x, h = 2:4) + h

ans =

         2         3         4
         6         6         8
        44        45        44
       124       126       124
       422       423       424
     31416     31416     31416
   1081178   1081179   1081180