{"id":19672719,"url":"https://github.com/halilozel1903/kotlinprimenumber","last_synced_at":"2026-06-12T19:31:48.839Z","repository":{"id":188048336,"uuid":"618955657","full_name":"halilozel1903/KotlinPrimeNumber","owner":"halilozel1903","description":"This example finds prime numbers in the Kotlin. 👀 3️⃣ 5️⃣","archived":false,"fork":false,"pushed_at":"2024-03-16T12:46:51.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-10T03:49:32.726Z","etag":null,"topics":["kotlin","kotlin-android","kotlin-basic","kotlin-example","kotlin-examples","kotlin-language","kotlin-learning","kotlin-tutorial","prime-number","prime-number-algorithm","prime-number-calculations","prime-numbers","prime-numbers-generation"],"latest_commit_sha":null,"homepage":"https://medium.com/@halilozel1903","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halilozel1903.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-03-25T20:44:51.000Z","updated_at":"2023-03-25T21:08:38.000Z","dependencies_parsed_at":"2024-03-16T14:25:59.106Z","dependency_job_id":null,"html_url":"https://github.com/halilozel1903/KotlinPrimeNumber","commit_stats":null,"previous_names":["halilozel1903/kotlinprimenumber"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FKotlinPrimeNumber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FKotlinPrimeNumber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FKotlinPrimeNumber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FKotlinPrimeNumber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halilozel1903","download_url":"https://codeload.github.com/halilozel1903/KotlinPrimeNumber/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240981564,"owners_count":19888346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["kotlin","kotlin-android","kotlin-basic","kotlin-example","kotlin-examples","kotlin-language","kotlin-learning","kotlin-tutorial","prime-number","prime-number-algorithm","prime-number-calculations","prime-numbers","prime-numbers-generation"],"created_at":"2024-11-11T17:13:07.390Z","updated_at":"2026-06-12T19:31:43.759Z","avatar_url":"https://github.com/halilozel1903.png","language":"Kotlin","funding_links":["https://www.buymeacoffee.com/halilozel1903"],"categories":[],"sub_categories":[],"readme":"## Kotlin Prime Number 🔢 🎖️ 💥\n\n![Kotlin Prime Number](https://www.zealousweb.com/wp-content/uploads/2020/05/Banner-2.jpg)\n\nA prime number is a positive integer greater than 1 that has no positive integer divisors other than 1 and itself. In other words, a prime number is a number that can only be divided evenly by 1 and itself.\n\nHere's a simple program in `Kotlin` to find all prime numbers up to a given number:\n\n```kotlin\nfun main() {\n    val limit = 20\n    println(\"Prime numbers up to $limit: ${(2..limit).filter { it.isPrime() }.joinToString(\", \")}\")\n}\n\nfun Int.isPrime(): Boolean = this \u003c= 1 || (2 until this).none { this % it == 0 }\n```\nIn this program, we start by setting a variable limit to the maximum number we want to check for prime numbers. In this case, we've set it to `20`.\n\nNext, we print a message to indicate that we're looking for prime numbers up to the limit.\n\nWe then use a for loop to iterate through all the numbers from 2 up to the limit. For each number, we call the `isPrime()` to determine whether it's a prime number.\n\nThe `isPrime()` takes an integer parameter number and returns a boolean value indicating whether it's a prime number. First, we check if the number is less than or equal to 1, in which case it's not a prime number. Then we use another for loop to check all the numbers from 2 up to one less than the number itself. If we find any number that divides the number evenly, we know it's not a prime number and we return false. If we make it through the entire loop without finding a divisor, we know the number is a prime number and we return true.\n\nWhen we run the program, it will output all the prime numbers up to the limit we set:\n\n```kotlin\nPrime numbers up to 20: 2 3 5 7 11 13 17 19\n```\n## Donation 💸\n\nYou can support by buying a coffee. ☕️\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/halilozel1903)\n\n\n## License ℹ️\n```\nMIT License\n\nCopyright (c) 2024 Halil OZEL\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fkotlinprimenumber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalilozel1903%2Fkotlinprimenumber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fkotlinprimenumber/lists"}