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

Commit 71b48c8

Browse files
fix: standard style problems
1 parent 190ebb0 commit 71b48c8

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

‎Project-Euler/Problem025.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
* @see {@link https://projecteuler.net/problem=25}
55
*
66
* The Fibonacci sequence is defined by the recurrence relation:
7-
*
7+
*
88
* Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
9-
*
9+
*
1010
* Hence the first 12 terms will be:
11-
*
11+
*
1212
* F1 = 1
1313
* F2 = 1
1414
* F3 = 2
@@ -28,18 +28,18 @@
2828

2929
// brute force method
3030

31-
function fibonacciIndex(t = 1000) {
32-
let digits = 10n**BigInt(t-1),
33-
fib0 = BigInt(0),
34-
fib1 = BigInt(1),
35-
index = 1
36-
while (fib1 < digits) { // using this to compare number of digits instead of .toString() significantly improved run time
31+
function fibonacciIndex(t = 1000) {
32+
const digits = 10n**BigInt(t-1)
33+
letfib0 = BigInt(0)
34+
letfib1 = BigInt(1)
35+
let index = 1
36+
while (fib1 < digits) { // using this to compare number of digits instead of .toString() significantly improved run time
3737
const tempfib = fib1
3838
fib1 = fib1 + fib0
3939
fib0 = tempfib
4040
index += 1
4141
}
42-
return(index)
42+
return(index)
4343
}
4444

4545
export { fibonacciIndex }

‎Project-Euler/test/Problem025.test.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import { fibonacciIndex } from '../Problem025'
22

3-
describe('Check Problem 25 - 1000 digit Fibonnaci number', () => {
4-
it('First term of the Fibonnaci sequence containing 3 digits', () => {
5-
expect(fibonacciIndex(3)).toBe(12)
6-
})
3+
describe('Check Problem 25 - 1000 digit Fibonnaci number', () => {
4+
it('First term of the Fibonnaci sequence containing 3 digits', () => {
5+
expect(fibonacciIndex(3)).toBe(12)
6+
})
77

8-
it('First term of the Fibonnaci sequence containing 10 digits', () => {
9-
expect(fibonacciIndex(10)).toBe(45)
10-
})
8+
it('First term of the Fibonnaci sequence containing 10 digits', () => {
9+
expect(fibonacciIndex(10)).toBe(45)
10+
})
1111

12-
it('First term of the Fibonnaci sequence containing 50 digits', () => {
13-
expect(fibonacciIndex(50)).toBe(237)
14-
})
12+
it('First term of the Fibonnaci sequence containing 50 digits', () => {
13+
expect(fibonacciIndex(50)).toBe(237)
14+
})
1515

16-
it('First term of the Fibonnaci sequence containing 100 digits', () => {
17-
expect(fibonacciIndex(100)).toBe(476)
18-
})
16+
it('First term of the Fibonnaci sequence containing 100 digits', () => {
17+
expect(fibonacciIndex(100)).toBe(476)
18+
})
1919

20-
it('First term of the Fibonnaci sequence containing 1000 digits', () => {
21-
expect(fibonacciIndex(1000)).toBe(4782)
22-
})
23-
24-
it('First term of the Fibonnaci sequence containing 10000 digits', () => {
25-
expect(fibonacciIndex(10000)).toBe(47847)
26-
})
20+
it('First term of the Fibonnaci sequence containing 1000 digits', () => {
21+
expect(fibonacciIndex(1000)).toBe(4782)
22+
})
23+
24+
it('First term of the Fibonnaci sequence containing 10000 digits', () => {
25+
expect(fibonacciIndex(10000)).toBe(47847)
26+
})
2727
})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /