prog.pl 658 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/perl
  2. # a(n) is the least start of exactly n consecutive numbers k that are sqrt(k)-smooth (A048098), or -1 in no such run exists.
  3. # https://oeis.org/A355434
  4. use 5.020;
  5. use strict;
  6. use warnings;
  7. use ntheory qw(:all);
  8. my @table;
  9. my $count;
  10. for(my $n = 1; ; ++$n) {
  11. $count = 0;
  12. while (is_smooth($n, sqrtint($n))) {
  13. ++$n;
  14. ++$count;
  15. }
  16. if (not $table[$count]) {
  17. $table[$count] = 1;
  18. say "a($count) = ", $n-$count;
  19. }
  20. }
  21. __END__
  22. a(1) = 1
  23. a(0) = 3
  24. a(2) = 8
  25. a(3) = 48
  26. a(4) = 1518
  27. a(5) = 5828
  28. a(6) = 28032
  29. a(8) = 290783
  30. a(7) = 304260
  31. a(9) = 1255500
  32. a(10) = 4325170
  33. a(11) = 11135837
  34. a(12) = 18567909