Skip to main content
syntax highlighting
Source Link

PHP, 51 45 43 37 characters

function f($n){return~~$n-(~~$n>$n);} This should be able to be applied to most languages that do not support the n%1 trick.
function f($n){return~~$n-(~~$n>$n);}

This should be able to be applied to most languages that do not support the n%1 trick.

PHP, 51 45 43 37 characters

function f($n){return~~$n-(~~$n>$n);} This should be able to be applied to most languages that do not support the n%1 trick.

PHP, 51 45 43 37 characters

function f($n){return~~$n-(~~$n>$n);}

This should be able to be applied to most languages that do not support the n%1 trick.

added 4 characters in body; edited body
Source Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59

PHP, 51 45 4343 37 characters

function f($n){return(int)$nreturn~~$n-((int)$n>$n~~$n>$n);} This should be able to be applied to most languages that do not support the n%1 trick.

PHP, 51 45 43 characters

function f($n){return(int)$n-((int)$n>$n);} This should be able to be applied to most languages that do not support the n%1 trick.

PHP, 51 45 43 37 characters

function f($n){return~~$n-(~~$n>$n);} This should be able to be applied to most languages that do not support the n%1 trick.
added 4 characters in body; added 8 characters in body; edited body
Source Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59

PHP, 5151 45 43 characters

function f($n){return(int)$n>$n?(int)$n-1:((int)$n;$n>$n);} This should be able to be applied to most languages that do not support the n%1 trick.

PHP, 51 characters

function f($n){return(int)$n>$n?(int)$n-1:(int)$n;} This should be able to be applied to most languages that do not support the n%1 trick.

PHP, 51 45 43 characters

function f($n){return(int)$n-((int)$n>$n);} This should be able to be applied to most languages that do not support the n%1 trick.
deleted 3 characters in body
Source Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59
Loading
Source Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59
Loading