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 5e82f25

Browse files
Add 1st attempt: DAILY/Attempting → 354; Update README links
1 parent e88004f commit 5e82f25

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed
Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
11
// ===================================
2-
// ProbName - Solution
2+
// Integer Complexity 1 - Solution
33
// ===================================
4+
5+
// Based on strategy outlined in notes, we can quickly find factors
6+
7+
function intComplexityOne(number) {
8+
// default value - we can assume number > 1
9+
// initial array to hold arrays of factor pairs
10+
let factorSumArr = [];
11+
12+
// Define upper bound for loop based on strategy in notes
13+
let factorUpperBound = Math.floor(Math.sqrt(number));
14+
15+
// take each integer between one and the factorUpperBound...
16+
for (let i = 1; i <= factorUpperBound; i++) {
17+
// ...and see if it divides evenly into the number.
18+
if (number % i === 0) {
19+
// if it does, take i's factor pair...
20+
let pair = number / i;
21+
22+
// ...add it to i...
23+
let pairSum = pair + i;
24+
25+
// ...and push that value to the factorSum array
26+
factorSumArr.push(pairSum);
27+
}
28+
}
29+
// at this point all factor pairs have been added together and pushed into the factorSum array
30+
// return the lowest number from this array of values
31+
factorSumArr.sort();
32+
return factorSumArr[0];
33+
}
34+
35+
// intComplexityOne(12345); => 12346 [???]

‎DailyProgrammer/Attempting/354: Integer Complexity 1/354: Integer Complexity 1 - Notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,5 @@ BASE UPPER BOUND
107107
108108
upperBound test pass; 140 - 11 = 129 numbers saved from testing
109109
```
110+
111+
Don't even need internal array; just add on the spot.

‎DailyProgrammer/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
## Need to Revisit
1010

11-
| Problem | Revisited | Code Link |
12-
| --------------------------------- | ----------- | ----------------------------------- |
13-
| #354 [Easy]: Integer Complexity 1 | 07-Sep-2018 | [Problem](Update link after commit) |
11+
| Problem | Revisited | Code Link |
12+
| --------------------------------- | ----------- | ------------------------------- |
13+
| #354 [Easy]: Integer Complexity 1 | 07-Sep-2018 | [Problem](https://git.io/fAzMg) |
1414

1515
---
1616

‎README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ My notes and answers as JS files are also available to show my answer and steps
1818

1919
### Last 5 Revisited
2020

21-
| Problem | Source | Revisited | Prompt & Code |
22-
| --------------------------------- | ------ | ----------- | ----------------------------------- |
23-
| #354 [Easy]: Integer Complexity 1 | DAILY | 07-Sep-2018 | [Problem](Update link after commit) |
24-
| #25 - 1000-digit Fibonacci number | EULER | 02-Sep-2018 | [Prob 25](https://git.io/fARt7) |
25-
| #5 - Smallest multiple | EULER | 31-Jul-2018 | [Prob 5](https://git.io/fARtX) |
26-
| #22L - Names scores (lite) | EULER | 31-Jul-2018 | [Prob 22L](https://git.io/fARtH) |
27-
| #4 - Largest palindrome product | EULER | 30-Jul-2018 | [Prob 4](https://git.io/fARt6) |
28-
| #7 - 10 001st prime | EULER | 29-Jul-2018 | [Prob 7](https://git.io/fARtM) |
21+
| Problem | Source | Revisited | Prompt & Code |
22+
| --------------------------------- | ------ | ----------- | -------------------------------- |
23+
| #354 [Easy]: Integer Complexity 1 | DAILY | 07-Sep-2018 | [Problem](https://git.io/fAzMg) |
24+
| #25 - 1000-digit Fibonacci number | EULER | 02-Sep-2018 | [Prob 25](https://git.io/fARt7) |
25+
| #5 - Smallest multiple | EULER | 31-Jul-2018 | [Prob 5](https://git.io/fARtX) |
26+
| #22L - Names scores (lite) | EULER | 31-Jul-2018 | [Prob 22L](https://git.io/fARtH) |
27+
| #4 - Largest palindrome product | EULER | 30-Jul-2018 | [Prob 4](https://git.io/fARt6) |
28+
| #7 - 10 001st prime | EULER | 29-Jul-2018 | [Prob 7](https://git.io/fARtM) |
2929

3030
### [View Master List of Problems](https://git.io/fAz0p)
3131

0 commit comments

Comments
(0)

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