Skip to content

Commit 292d8f5

Browse files
committed
chore: minor improvements
- added more clarity to README instructions - added more resource intensive test cases - fixed bug in Go test assertions
1 parent 91a63d4 commit 292d8f5

5 files changed

Lines changed: 31 additions & 10 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
.vscode
2+
.idea
13
.DS_Store
24

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@
22

33
## The Sieve of Eratosthenes
44

5-
Prime numbers have many modern day applications and a long history in mathematics. Utilizing your own resources research the sieve of Eratosthenes, an algorithm for generating prime numbers. Based on your research, implement an API that allows the caller to retrieve the Nth prime number.
6-
Some stub code and a test suite have been provided as a convenience, however, you are encouraged to deviate from Eratosthenes's algorithm, modify the existing functions/methods or anything else that might showcase your ability provided the following requirements are satisfied.
7-
Stub code has been provided in Go, C#, and Javascript. Please use the language that is most appropriate based on your own skillset
5+
Prime numbers have many modern day applications and a long history in
6+
mathematics. Utilizing your own resources research the sieve of Eratosthenes,
7+
an algorithm for generating prime numbers. Based on your research, implement
8+
an API that allows the caller to retrieve the Nth prime number.
9+
Some stub code and a test suite have been provided as a convenience, however,
10+
you are encouraged to deviate from Eratosthenes's algorithm, modify the
11+
existing functions/methods or anything else that might showcase your ability
12+
provided the following requirements are satisfied.
13+
14+
Stub code has been provided in Go, C#, and Javascript. Please choose from one
15+
of the provided language stubs that is most appropriate based on your own
16+
skill set and the position you are applying for.
817

918
### Requirements
1019

@@ -19,6 +28,9 @@ Stub code has been provided in Go, C#, and Javascript. Please use the language t
1928

2029
### Considerations
2130

31+
You may add more tests or restructure tests, but you may NOT change or remove
32+
the existing test outcomes; eg- f(0)=2, f(19)=71, f(99)=541, ..., f(10000000)=179424691
33+
2234
During the technical interview, your submission will be discussed, and you will be evaluated in the following areas:
2335

2436
- Technical ability

csharp/Sieve.Tests/UnitTest1.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public void TestNthPrime()
1515
Assert.AreEqual(7793, sieve.NthPrime(986));
1616
Assert.AreEqual(17393, sieve.NthPrime(2000));
1717
Assert.AreEqual(15485867, sieve.NthPrime(1000000));
18+
Assert.AreEqual(179424691, sieve.NthPrime(10000000));
19+
//Assert.AreEqual(2038074751, sieve.NthPrime(100000000));
1820
}
1921
}
2022
}

go/pkg/sieve/sieve_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ import (
1010
func TestNthPrime(t *testing.T) {
1111
sieve := NewSieve()
1212

13-
assert.Equal(t, 2, sieve.NthPrime(0))
14-
assert.Equal(t, 71, sieve.NthPrime(19))
15-
assert.Equal(t, 541, sieve.NthPrime(99))
16-
assert.Equal(t, 3581, sieve.NthPrime(500))
17-
assert.Equal(t, 7793, sieve.NthPrime(986))
18-
assert.Equal(t, 17393, sieve.NthPrime(2000))
19-
assert.Equal(t, 15485867, sieve.NthPrime(1000000))
13+
assert.Equal(t, int64(2), sieve.NthPrime(0))
14+
assert.Equal(t, int64(71), sieve.NthPrime(19))
15+
assert.Equal(t, int64(541), sieve.NthPrime(99))
16+
assert.Equal(t, int64(3581), sieve.NthPrime(500))
17+
assert.Equal(t, int64(7793), sieve.NthPrime(986))
18+
assert.Equal(t, int64(17393), sieve.NthPrime(2000))
19+
assert.Equal(t, int64(15485867), sieve.NthPrime(1000000))
20+
assert.Equal(t, int64(15485867), sieve.NthPrime(1000000))
21+
assert.Equal(t, int64(179424691), sieve.NthPrime(10000000))
22+
//assert.Equal(t, int64(2038074751), sieve.NthPrime(100000000))
2023
}
2124

2225
func FuzzNthPrime(f *testing.F) {

javascript/Sieve/sieve.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ describe("Sieve", () => {
1010
expect(sieve.NthPrime(986)).toBe(7793);
1111
expect(sieve.NthPrime(2000)).toBe(17393);
1212
expect(sieve.NthPrime(1000000)).toBe(15485867);
13+
expect(sieve.NthPrime(10000000)).toBe(179424691);
14+
//expect(sieve.NthPrime(100000000)).toBe(2038074751);
1315
});
1416
});

0 commit comments

Comments
 (0)