Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0fab492

Browse files
appgurueugithub-actions
and
github-actions
authored
fix: Project Euler P35 off-by-one error (#1238)
* fix: Project Euler P35 off-by-one error* Updated Documentation in README.mdCo-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent5364a1c commit0fab492

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

‎DIRECTORY.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
*[LocalMaximomPoint](Data-Structures/Array/LocalMaximomPoint.js)
5858
*[NumberOfLocalMaximumPoints](Data-Structures/Array/NumberOfLocalMaximumPoints.js)
5959
*[QuickSelect](Data-Structures/Array/QuickSelect.js)
60+
*[Reverse](Data-Structures/Array/Reverse.js)
6061
***Graph**
6162
*[Graph](Data-Structures/Graph/Graph.js)
6263
*[Graph2](Data-Structures/Graph/Graph2.js)
@@ -81,6 +82,7 @@
8182
***Tree**
8283
*[AVLTree](Data-Structures/Tree/AVLTree.js)
8384
*[BinarySearchTree](Data-Structures/Tree/BinarySearchTree.js)
85+
*[SegmentTree](Data-Structures/Tree/SegmentTree.js)
8486
*[Trie](Data-Structures/Tree/Trie.js)
8587
***Vectors**
8688
*[Vector2](Data-Structures/Vectors/Vector2.js)
@@ -105,18 +107,19 @@
105107
*[RodCutting](Dynamic-Programming/RodCutting.js)
106108
*[Shuf](Dynamic-Programming/Shuf.js)
107109
*[SieveOfEratosthenes](Dynamic-Programming/SieveOfEratosthenes.js)
108-
*[UniquePaths](Dynamic-Programming/UniquePaths.js)
109110
***Sliding-Window**
110111
*[LongestSubstringWithoutRepeatingCharacters](Dynamic-Programming/Sliding-Window/LongestSubstringWithoutRepeatingCharacters.js)
111112
*[PermutationinString](Dynamic-Programming/Sliding-Window/PermutationinString.js)
112113
*[SudokuSolver](Dynamic-Programming/SudokuSolver.js)
113114
*[TrappingRainWater](Dynamic-Programming/TrappingRainWater.js)
114115
*[TribonacciNumber](Dynamic-Programming/TribonacciNumber.js)
116+
*[UniquePaths](Dynamic-Programming/UniquePaths.js)
115117
*[ZeroOneKnapsack](Dynamic-Programming/ZeroOneKnapsack.js)
116118
***Geometry**
117119
*[ConvexHullGraham](Geometry/ConvexHullGraham.js)
118120
***Graphs**
119121
*[BellmanFord](Graphs/BellmanFord.js)
122+
*[BinaryLifting](Graphs/BinaryLifting.js)
120123
*[BreadthFirstSearch](Graphs/BreadthFirstSearch.js)
121124
*[BreadthFirstShortestPath](Graphs/BreadthFirstShortestPath.js)
122125
*[ConnectedComponents](Graphs/ConnectedComponents.js)
@@ -126,6 +129,7 @@
126129
*[Dijkstra](Graphs/Dijkstra.js)
127130
*[DijkstraSmallestPath](Graphs/DijkstraSmallestPath.js)
128131
*[FloydWarshall](Graphs/FloydWarshall.js)
132+
*[Kosaraju](Graphs/Kosaraju.js)
129133
*[KruskalMST](Graphs/KruskalMST.js)
130134
*[NodeNeighbors](Graphs/NodeNeighbors.js)
131135
*[NumberOfIslands](Graphs/NumberOfIslands.js)
@@ -158,6 +162,7 @@
158162
*[EulerMethod](Maths/EulerMethod.js)
159163
*[EulersTotient](Maths/EulersTotient.js)
160164
*[EulersTotientFunction](Maths/EulersTotientFunction.js)
165+
*[ExponentialFunction](Maths/ExponentialFunction.js)
161166
*[ExtendedEuclideanGCD](Maths/ExtendedEuclideanGCD.js)
162167
*[Factorial](Maths/Factorial.js)
163168
*[Factors](Maths/Factors.js)
@@ -190,6 +195,7 @@
190195
*[MeanSquareError](Maths/MeanSquareError.js)
191196
*[MidpointIntegration](Maths/MidpointIntegration.js)
192197
*[MobiusFunction](Maths/MobiusFunction.js)
198+
*[ModularArithmetic](Maths/ModularArithmetic.js)
193199
*[ModularBinaryExponentiationRecursive](Maths/ModularBinaryExponentiationRecursive.js)
194200
*[NumberOfDigits](Maths/NumberOfDigits.js)
195201
*[Palindrome](Maths/Palindrome.js)
@@ -209,6 +215,7 @@
209215
*[ReversePolishNotation](Maths/ReversePolishNotation.js)
210216
*[ShorsAlgorithm](Maths/ShorsAlgorithm.js)
211217
*[SieveOfEratosthenes](Maths/SieveOfEratosthenes.js)
218+
*[SieveOfEratosthenesIntArray](Maths/SieveOfEratosthenesIntArray.js)
212219
*[SimpsonIntegration](Maths/SimpsonIntegration.js)
213220
*[Softmax](Maths/Softmax.js)
214221
*[SquareRoot](Maths/SquareRoot.js)
@@ -243,6 +250,7 @@
243250
*[Problem023](Project-Euler/Problem023.js)
244251
*[Problem025](Project-Euler/Problem025.js)
245252
*[Problem028](Project-Euler/Problem028.js)
253+
*[Problem035](Project-Euler/Problem035.js)
246254
*[Problem044](Project-Euler/Problem044.js)
247255
***Recursive**
248256
*[BinaryEquivalent](Recursive/BinaryEquivalent.js)
@@ -317,6 +325,7 @@
317325
*[CheckRearrangePalindrome](String/CheckRearrangePalindrome.js)
318326
*[CheckSnakeCase](String/CheckSnakeCase.js)
319327
*[CheckWordOccurrence](String/CheckWordOccurrence.js)
328+
*[CountLetters](String/CountLetters.js)
320329
*[CountSubstrings](String/CountSubstrings.js)
321330
*[CountVowels](String/CountVowels.js)
322331
*[CreatePermutations](String/CreatePermutations.js)

‎Project-Euler/Problem035.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ function problem35 (n) {
1515
if(n<2){
1616
thrownewError('Invalid input')
1717
}
18-
constlist=sieveOfEratosthenes(n).filter(prime=>!prime.toString().match(/[024568]/))// Get a list of primes without 0, 2, 4, 5, 6, 8
18+
// Get a list of primes without 0, 2, 4, 5, 6, 8; this discards the circular primes 2 & 5
19+
constlist=sieveOfEratosthenes(n).filter(prime=>!prime.toString().match(/[024568]/))
1920

2021
constresult=list.filter((number,_idx,arr)=>{
2122
conststr=String(number)
@@ -28,7 +29,7 @@ function problem35 (n) {
2829
returntrue// If all rotations are prime, then the number is circular prime
2930
})
3031

31-
returnresult.length+1// Add 2 to the result because2 is a circular prime
32+
returnresult.length+2// Add 2 to the result becausethe circular primes 2 & 5 were discarded
3233
}
3334

3435
export{problem35}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp