{"id":16687993,"url":"https://github.com/danielpclark/multiples","last_synced_at":"2026-04-17T10:33:09.520Z","repository":{"id":142007147,"uuid":"75723077","full_name":"danielpclark/multiples","owner":"danielpclark","description":"Creates enumerators that step through integers from a union of two infinite sets of multiples.","archived":false,"fork":false,"pushed_at":"2016-12-06T15:18:37.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T17:27:16.195Z","etag":null,"topics":["creates-enumerators","enumerator","iterator","math","mathematics","palindrome","union"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielpclark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-06T10:59:15.000Z","updated_at":"2016-12-06T11:25:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"f30726ce-0c1c-4f0e-a222-2fdd4b325455","html_url":"https://github.com/danielpclark/multiples","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/danielpclark/multiples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpclark%2Fmultiples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpclark%2Fmultiples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpclark%2Fmultiples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpclark%2Fmultiples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielpclark","download_url":"https://codeload.github.com/danielpclark/multiples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpclark%2Fmultiples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31925488,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T10:19:20.377Z","status":"ssl_error","status_checked_at":"2026-04-17T10:19:18.682Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["creates-enumerators","enumerator","iterator","math","mathematics","palindrome","union"],"created_at":"2024-10-12T15:26:20.918Z","updated_at":"2026-04-17T10:33:09.500Z","avatar_url":"https://github.com/danielpclark.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multiples\n\nCreates enumerators that step through integers from a union of two multiples.\nA pattern from the two numbers is determined (much like two frequencies create\na pattern) and the resulting palindrome is given to a custom Enumerator for you\nto use.\n\nI've created this gem from a delightful discovery I made.  When going through all\nthe numbers that are multiples of two different digits a pattern comes through.\nThis pattern is a palindrome.  See for yourself:\n\n```\nFor multiples of 3 with 5 we have.\n\n3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 39 40 42 45\n3 2 1 3 1  2  3  3  2  1  3  1  2  3  3  2  1  3  1  2  3\n```\n\nThe palindrome for the above differences example is `3,2,1,3,1,2,3`.  I thought this\nmay be true for other numbers as well so lets look at 4 with 5.\n\n```\n4 5 8 10 12 15 16 20 24 25 28 30 32 35 36 40\n4 1 3 2  2  3  1  4  4  1  3  2  2  3  1  4\n```\n\nAs you can see from this example another palindrome has arisen `4,1,3,2,2,3,1,4`. Upon\nfurther study of these patterns I have also found that the palindrome will always be the\nsame length as the two numbers added together minus one.  So 3 and 5's palindrome is the\nlength `3+5-1=7` and 4 and 5's palindromes length is `4+5-1=8`.  I wrote code that tests\nany two different digits and those are accurate lengths.\n\nSo if you'd like an iterator that steps through multiples without calculating every step\nof the way you may use this gem for that.\n\n### NOTES\n\n* If one of the numbers is divisible by the other than this rule doesn't apply.\n* The gem doesn't take into account zero and negative numbers.  If you wanted to you may progress backwards through negative numbers.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'multiples'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install multiples\n\n## Usage\n\n```ruby\nx = Multiples.new(3,5)\nx.next\n# =\u003e 3\n\nx.each do |val|\n  break val if val \u003e 14\nend\n# =\u003e 15\n\nx.lazy.select {|v| v % 10 == 0}.take(2).to_a\n# =\u003e [20, 30]\nx.next\n# =\u003e 33 \nx.phase\n# =\u003e 1\nx.prev\n# =\u003e 30\nx.phase\n# =\u003e 0\n\ny = Multiples.new(3,5)\n\ny.lazy.take(4).to_a\n# =\u003e [3, 5, 6, 9] \ny.next\n# =\u003e 10 \ny.prev\n# =\u003e 9 \n\ny.lazy.select {|v| v % 7 == 0 }.take(14).to_a\n# =\u003e [21, 35, 42, 63, 70, 84, 105, 126, 140, 147, 168, 175, 189, 210]\n```\n\n## Benchmark\n\nIf you reuse the Enumerator (rather than re-initialzing it) you will gain a\nperformance advantage of at least 100% (2x original).  If you create a new Enumerator each time\nyou use it your performance will be 30% worse than if you had not used this gem.\nSee the benchmark file in test/benches for an example and run `rake bench` to see\nthe results for yourself.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/danielpclark/multiples.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielpclark%2Fmultiples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielpclark%2Fmultiples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielpclark%2Fmultiples/lists"}