You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-12
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Write a program that tells if an integer is prime or not.
10
10
## The Journey:
11
11
12
12
### 01. [Base Programmer](01.BaseProgrammer.c)
13
-
Though you knew how prime number worked, it took a long time to come up with this logic. Also, You made several mistakes on the way. And now, you are proud of your brilliant solution.
13
+
Though you knew how prime numbers work, it took a long time to come up with this logic. Also, You made several mistakes on the way. But now, you are proud of your brilliant solution.
You don't need to calculate all the way to the end, finding one divisor is enough. So, just `return`, no need for 'flag'. `break` would do too, but `return` is better.
50
+
You don't need to calculate all the way to the end; finding one divisor is enough. So, just `return`; no need for 'flag'. `break` would do too, but `return` is better.
You have grown SMARTER, and halved the run time by checking divisibility with odd-numbers only. You also understand that looping till 'x/2' is enough.
67
+
You have grown SMARTER and have halved the run time by checking divisibility with odd-numbers only. You also understand that looping till 'x/2' is enough.
68
68
69
69
``` ProgrammerKaioken20.c
70
70
int prime_or_not(int x) {
@@ -116,7 +116,7 @@ int prime_check(int n){
116
116
```
117
117
118
118
### 06. [Pseudo Super Programmer](06.PseudoSuperProgrammer.cpp)
119
-
Now, you understand- **mere comment cannot make bad code look good**. So, you get rid of those crappy names plus annoying comments, and make the code truly readable.
119
+
Now, you understand- **mere comment cannot make bad code look good**. So, you get rid of those crappy names and annoying comments. And now, the code is truly readable.
You have come up with a more clever solution for computing '√n'. In fact, you don't really need to calculate it. <br>
174
-
`2 == number` instead of `number == 2` can save you from lots of trouble caused by mistyping one `=`; giving compilation error in place of undetectable bug.
174
+
You have come up with a more clever solution for computing '√n'. In fact, you don't really need to calculate it! <br>
175
+
`2 == number`, instead of `number == 2`, can save you from lots of troubles caused by mistyping one `=` by giving a compilation error in place of an undetectable bug.
As we don't need to check divisibility by all even numbers after checking by 2, the same goes for 3. So, now we are checking divisibility by only the odd numbers those are not multiple of 3.
197
+
As we don't need to check divisibility by all even numbers after checking by 2, the same goes for 3. So now, we are checking divisibility by only the odd numbers that are not multiples of 3.
Execution time is more important than memory consumption. And if you can do some preprocessing then you should. Thus, for smaller integers you have reduced the complexity from √n to 1.
250
+
Execution time is more important than memory consumption. And if you can do some preprocessing, then you should. Thus for smaller integers, you have reduced the complexity from √n to 1.
0 commit comments