Skip to main content
2 of 5
deleted 3 characters in body
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59

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.
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59