From 97da5e8324b545ecf7a4519648fd47205e22c6d0 Mon Sep 17 00:00:00 2001 From: narkunan Date: Sat, 23 May 2026 18:18:54 +0530 Subject: [PATCH 1/9] Sync instructions.md for prime-factors --- .../prime-factors/.docs/instructions.md | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/exercises/practice/prime-factors/.docs/instructions.md b/exercises/practice/prime-factors/.docs/instructions.md index b5cb1657..252cc8ee 100644 --- a/exercises/practice/prime-factors/.docs/instructions.md +++ b/exercises/practice/prime-factors/.docs/instructions.md @@ -10,21 +10,27 @@ Note that 1 is not a prime number. What are the prime factors of 60? -- Our first divisor is 2. 2 goes into 60, leaving 30. +- Our first divisor is 2. + 2 goes into 60, leaving 30. - 2 goes into 30, leaving 15. - - 2 doesn't go cleanly into 15. So let's move on to our next divisor, 3. + - 2 doesn't go cleanly into 15. + So let's move on to our next divisor, 3. - 3 goes cleanly into 15, leaving 5. - - 3 does not go cleanly into 5. The next possible factor is 4. - - 4 does not go cleanly into 5. The next possible factor is 5. + - 3 does not go cleanly into 5. + The next possible factor is 4. + - 4 does not go cleanly into 5. + The next possible factor is 5. - 5 does go cleanly into 5. - We're left only with 1, so now, we're done. -Our successful divisors in that computation represent the list of prime -factors of 60: 2, 2, 3, and 5. +Our successful divisors in that computation represent the list of prime factors of 60: 2, 2, 3, and 5. You can check this yourself: -- 2 * 2 * 3 * 5 -- = 4 * 15 -- = 60 -- Success! +```text +2 * 2 * 3 * 5 += 4 * 15 += 60 +``` + +Success! From 4e761893b4cc9f63bca404375f9d5da31d4fd8fb Mon Sep 17 00:00:00 2001 From: narkunan Date: Sat, 23 May 2026 18:19:22 +0530 Subject: [PATCH 2/9] updated contributor name --- exercises/practice/prime-factors/.meta/config.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exercises/practice/prime-factors/.meta/config.json b/exercises/practice/prime-factors/.meta/config.json index 44ed0537..8b6e6bd4 100644 --- a/exercises/practice/prime-factors/.meta/config.json +++ b/exercises/practice/prime-factors/.meta/config.json @@ -7,7 +7,8 @@ "kunicmarko20", "kytrinyx", "petemcfarlane", - "yisraeldov" + "yisraeldov", + "Narkunan" ], "files": { "solution": [ @@ -22,5 +23,5 @@ }, "blurb": "Compute the prime factors of a given natural number.", "source": "The Prime Factors Kata by Uncle Bob", - "source_url": "https://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata" + "source_url": "https://web.archive.org/web/20221026171801/http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata" } From 4fd3e3acda1b5ec77d94219ca92bd2c40313fb3e Mon Sep 17 00:00:00 2001 From: narkunan Date: Sat, 23 May 2026 18:19:46 +0530 Subject: [PATCH 3/9] Sync tests.toml for prime-factors --- .../practice/prime-factors/.meta/tests.toml | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/exercises/practice/prime-factors/.meta/tests.toml b/exercises/practice/prime-factors/.meta/tests.toml index f3f05a3e..6f9cc8ce 100644 --- a/exercises/practice/prime-factors/.meta/tests.toml +++ b/exercises/practice/prime-factors/.meta/tests.toml @@ -1,6 +1,13 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [924fc966-a8f5-4288-82f2-6b9224819ccd] description = "no factors" @@ -8,12 +15,27 @@ description = "no factors" [17e30670-b105-4305-af53-ddde182cb6ad] description = "prime number" +[238d57c8-4c12-42ef-af34-ae4929f94789] +description = "another prime number" + [f59b8350-a180-495a-8fb1-1712fbee1158] description = "square of a prime" +[756949d3-3158-4e3d-91f2-c4f9f043ee70] +description = "product of first prime" + [bc8c113f-9580-4516-8669-c5fc29512ceb] description = "cube of a prime" +[7d6a3300-a4cb-4065-bd33-0ced1de6cb44] +description = "product of second prime" + +[073ac0b2-c915-4362-929d-fc45f7b9a9e4] +description = "product of third prime" + +[6e0e4912-7fb6-47f3-a9ad-dbcd79340c75] +description = "product of first and second prime" + [00485cd3-a3fe-4fbe-a64a-a4308fc1f870] description = "product of primes and non-primes" From 6af2f47ac589e30a8c3c7ee786a1b05e172faedb Mon Sep 17 00:00:00 2001 From: narkunan Date: Sat, 23 May 2026 18:20:37 +0530 Subject: [PATCH 4/9] Removed strict types comment --- .../practice/prime-factors/.meta/example.php | 22 ------------------- .../prime-factors/PrimeFactorsTest.php | 22 ------------------- 2 files changed, 44 deletions(-) diff --git a/exercises/practice/prime-factors/.meta/example.php b/exercises/practice/prime-factors/.meta/example.php index 7a817641..90198824 100644 --- a/exercises/practice/prime-factors/.meta/example.php +++ b/exercises/practice/prime-factors/.meta/example.php @@ -1,27 +1,5 @@ . - * - * To disable strict typing, comment out the directive below. - */ - declare(strict_types=1); function factors($n) diff --git a/exercises/practice/prime-factors/PrimeFactorsTest.php b/exercises/practice/prime-factors/PrimeFactorsTest.php index d564a028..f2153e4c 100644 --- a/exercises/practice/prime-factors/PrimeFactorsTest.php +++ b/exercises/practice/prime-factors/PrimeFactorsTest.php @@ -1,27 +1,5 @@ . - * - * To disable strict typing, comment out the directive below. - */ - declare(strict_types=1); use PHPUnit\Framework\TestCase; From 82638426dd957e63b825170f265268ae014cfc36 Mon Sep 17 00:00:00 2001 From: narkunan Date: Sat, 23 May 2026 18:44:50 +0530 Subject: [PATCH 5/9] synced test cases for prime factors --- .../prime-factors/PrimeFactorsTest.php | 78 ++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/exercises/practice/prime-factors/PrimeFactorsTest.php b/exercises/practice/prime-factors/PrimeFactorsTest.php index f2153e4c..f914f606 100644 --- a/exercises/practice/prime-factors/PrimeFactorsTest.php +++ b/exercises/practice/prime-factors/PrimeFactorsTest.php @@ -2,45 +2,121 @@ declare(strict_types=1); +use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; class PrimeFactorsTest extends TestCase { + public static function setUpBeforeClass(): void { require_once 'PrimeFactors.php'; } + /** + * uuid: 924fc966-a8f5-4288-82f2-6b9224819ccd + */ + #[TestDox('no factors')] public function testNoFactors(): void { $this->assertSame([], factors(1)); } + /** + * uuid: 17e30670-b105-4305-af53-ddde182cb6ad + */ + #[TestDox('prime number')] public function testOneFactor(): void { $this->assertSame([2], factors(2)); } + /** + * uuid: 238d57c8-4c12-42ef-af34-ae4929f94789 + */ + #[TestDox('another prime number')] + public function testAnotherPrimeNumber(): void + { + $this->assertSame([3], factors(3)); + } + + /** + * uuid: f59b8350-a180-495a-8fb1-1712fbee1158 + */ + #[TestDox('square of a prime')] public function testSquareOfPrime(): void { $this->assertSame([3, 3], factors(9)); } + /** + * uuid: 756949d3-3158-4e3d-91f2-c4f9f043ee70 + */ + #[TestDox('product of first prime')] + public function testProductOfFirstPrime(): void + { + $this->assertSame([2,2], factors(4)); + } + + /** + * uuid: bc8c113f-9580-4516-8669-c5fc29512ceb + */ + #[TestDox('cube of a prime')] public function testCubeOfPrime(): void { $this->assertSame([2, 2, 2], factors(8)); } - public function testProductOfPrimesAndNon(): void + /** + * uuid: 7d6a3300-a4cb-4065-bd33-0ced1de6cb44 + */ + #[TestDox('product of second prime')] + public function testProductOfSecondPrime(): void + { + $this->assertSame([3,3,3], factors(27)); + } + + /** + * uuid: 073ac0b2-c915-4362-929d-fc45f7b9a9e4 + */ + #[TestDox('product of third prime')] + public function testProductOfThirdPrime(): void + { + $this->assertSame([5,5,5,5], factors(625)); + } + + /** + * uuid: 6e0e4912-7fb6-47f3-a9ad-dbcd79340c75 + */ + #[TestDox('product of first and second prime')] + public function testProductOfFirstAndSecondPrime(): void + { + $this->assertSame([2,3], factors(6)); + } + + /** + * uuid: 00485cd3-a3fe-4fbe-a64a-a4308fc1f870 + */ + #[TestDox('product of primes and non-primes')] + public function testProductOfPrimesAndNonPrime(): void { $this->assertEquals([2, 2, 3], factors(12)); } + /** + * uuid: 02251d54-3ca1-4a9b-85e1-b38f4b0ccb91 + */ + #[TestDox('product of prime')] public function testProductOfPrimes(): void { $this->assertEquals([5, 17, 23, 461], factors(901255)); } + /** + * uuid: 070cf8dc-e202-4285-aa37-8d775c9cd473 + */ + #[TestDox('factors include a large prime')] + public function testFactorsIncludeLargePrime(): void { $this->assertEquals([11, 9539, 894119], factors(93819012551)); From 9d19b86ec0f31a908028cf998a313511b65464e3 Mon Sep 17 00:00:00 2001 From: narkunan Date: Sat, 23 May 2026 18:49:34 +0530 Subject: [PATCH 6/9] Fixed Test file linting issue --- exercises/practice/prime-factors/PrimeFactorsTest.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/exercises/practice/prime-factors/PrimeFactorsTest.php b/exercises/practice/prime-factors/PrimeFactorsTest.php index f914f606..a59cb5d9 100644 --- a/exercises/practice/prime-factors/PrimeFactorsTest.php +++ b/exercises/practice/prime-factors/PrimeFactorsTest.php @@ -7,7 +7,6 @@ class PrimeFactorsTest extends TestCase { - public static function setUpBeforeClass(): void { require_once 'PrimeFactors.php'; @@ -35,7 +34,7 @@ public function testOneFactor(): void * uuid: 238d57c8-4c12-42ef-af34-ae4929f94789 */ #[TestDox('another prime number')] - public function testAnotherPrimeNumber(): void + public function testAnotherPrimeNumber(): void { $this->assertSame([3], factors(3)); } @@ -53,7 +52,7 @@ public function testSquareOfPrime(): void * uuid: 756949d3-3158-4e3d-91f2-c4f9f043ee70 */ #[TestDox('product of first prime')] - public function testProductOfFirstPrime(): void + public function testProductOfFirstPrime(): void { $this->assertSame([2,2], factors(4)); } @@ -71,7 +70,7 @@ public function testCubeOfPrime(): void * uuid: 7d6a3300-a4cb-4065-bd33-0ced1de6cb44 */ #[TestDox('product of second prime')] - public function testProductOfSecondPrime(): void + public function testProductOfSecondPrime(): void { $this->assertSame([3,3,3], factors(27)); } @@ -80,7 +79,7 @@ public function testProductOfSecondPrime(): void * uuid: 073ac0b2-c915-4362-929d-fc45f7b9a9e4 */ #[TestDox('product of third prime')] - public function testProductOfThirdPrime(): void + public function testProductOfThirdPrime(): void { $this->assertSame([5,5,5,5], factors(625)); } @@ -89,7 +88,7 @@ public function testProductOfThirdPrime(): void * uuid: 6e0e4912-7fb6-47f3-a9ad-dbcd79340c75 */ #[TestDox('product of first and second prime')] - public function testProductOfFirstAndSecondPrime(): void + public function testProductOfFirstAndSecondPrime(): void { $this->assertSame([2,3], factors(6)); } From 11928dc4b2571e9be02c8028ef8e13dfe916c991 Mon Sep 17 00:00:00 2001 From: narkunan Date: Sun, 24 May 2026 18:36:59 +0530 Subject: [PATCH 7/9] Fixed issue with the method names not matching --- .../prime-factors/PrimeFactorsTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/exercises/practice/prime-factors/PrimeFactorsTest.php b/exercises/practice/prime-factors/PrimeFactorsTest.php index a59cb5d9..2f3c21d1 100644 --- a/exercises/practice/prime-factors/PrimeFactorsTest.php +++ b/exercises/practice/prime-factors/PrimeFactorsTest.php @@ -43,7 +43,7 @@ public function testAnotherPrimeNumber(): void * uuid: f59b8350-a180-495a-8fb1-1712fbee1158 */ #[TestDox('square of a prime')] - public function testSquareOfPrime(): void + public function testSquareOfAPrime(): void { $this->assertSame([3, 3], factors(9)); } @@ -54,14 +54,14 @@ public function testSquareOfPrime(): void #[TestDox('product of first prime')] public function testProductOfFirstPrime(): void { - $this->assertSame([2,2], factors(4)); + $this->assertSame([2, 2], factors(4)); } /** * uuid: bc8c113f-9580-4516-8669-c5fc29512ceb */ #[TestDox('cube of a prime')] - public function testCubeOfPrime(): void + public function testCubeOfAPrime(): void { $this->assertSame([2, 2, 2], factors(8)); } @@ -72,7 +72,7 @@ public function testCubeOfPrime(): void #[TestDox('product of second prime')] public function testProductOfSecondPrime(): void { - $this->assertSame([3,3,3], factors(27)); + $this->assertSame([3, 3, 3], factors(27)); } /** @@ -81,7 +81,7 @@ public function testProductOfSecondPrime(): void #[TestDox('product of third prime')] public function testProductOfThirdPrime(): void { - $this->assertSame([5,5,5,5], factors(625)); + $this->assertSame([5, 5, 5, 5], factors(625)); } /** @@ -90,14 +90,14 @@ public function testProductOfThirdPrime(): void #[TestDox('product of first and second prime')] public function testProductOfFirstAndSecondPrime(): void { - $this->assertSame([2,3], factors(6)); + $this->assertSame([2, 3], factors(6)); } /** * uuid: 00485cd3-a3fe-4fbe-a64a-a4308fc1f870 */ #[TestDox('product of primes and non-primes')] - public function testProductOfPrimesAndNonPrime(): void + public function testProductOfPrimesAndNonPrimes(): void { $this->assertEquals([2, 2, 3], factors(12)); } @@ -105,7 +105,7 @@ public function testProductOfPrimesAndNonPrime(): void /** * uuid: 02251d54-3ca1-4a9b-85e1-b38f4b0ccb91 */ - #[TestDox('product of prime')] + #[TestDox('product of primes')] public function testProductOfPrimes(): void { $this->assertEquals([5, 17, 23, 461], factors(901255)); @@ -116,7 +116,7 @@ public function testProductOfPrimes(): void */ #[TestDox('factors include a large prime')] - public function testFactorsIncludeLargePrime(): void + public function testFactorsIncludeALargePrime(): void { $this->assertEquals([11, 9539, 894119], factors(93819012551)); } From d57c89d601e9dd75b0012cd143927da87a50138e Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Sun, 24 May 2026 19:11:40 +0200 Subject: [PATCH 8/9] Allow student to return different order --- exercises/practice/prime-factors/PrimeFactorsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/prime-factors/PrimeFactorsTest.php b/exercises/practice/prime-factors/PrimeFactorsTest.php index 2f3c21d1..e2a964b4 100644 --- a/exercises/practice/prime-factors/PrimeFactorsTest.php +++ b/exercises/practice/prime-factors/PrimeFactorsTest.php @@ -90,7 +90,7 @@ public function testProductOfThirdPrime(): void #[TestDox('product of first and second prime')] public function testProductOfFirstAndSecondPrime(): void { - $this->assertSame([2, 3], factors(6)); + $this->assertEquals([2, 3], factors(6)); } /** From 55f52926bd7a5beae33459b13824ed05207f7c86 Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Sun, 24 May 2026 19:11:53 +0200 Subject: [PATCH 9/9] Drop empty line --- exercises/practice/prime-factors/PrimeFactorsTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/exercises/practice/prime-factors/PrimeFactorsTest.php b/exercises/practice/prime-factors/PrimeFactorsTest.php index e2a964b4..cf6c8c4f 100644 --- a/exercises/practice/prime-factors/PrimeFactorsTest.php +++ b/exercises/practice/prime-factors/PrimeFactorsTest.php @@ -115,7 +115,6 @@ public function testProductOfPrimes(): void * uuid: 070cf8dc-e202-4285-aa37-8d775c9cd473 */ #[TestDox('factors include a large prime')] - public function testFactorsIncludeALargePrime(): void { $this->assertEquals([11, 9539, 894119], factors(93819012551));