hickerson_series_of_almost_integers.sf 298 B

12345678910111213141516
  1. #!/usr/bin/ruby
  2. #
  3. ## https://rosettacode.org/wiki/Hickerson_series_of_almost_integers
  4. #
  5. func h(n) {
  6. n! / (2 * pow(2.log, n+1));
  7. }
  8.  
  9. for n in (1..17) {
  10. var hn = h(n).roundf(-3);
  11. "h(%2d) = %22s is%s almost an integer.\n".printf(
  12. n, hn, hn.to_s ~~ /\.[09]/ ? '' : ' NOT');
  13. }