Skip to content

Commit 0653099

Browse files
priydamkubdevPanquesito7
authored
chore: use Markdown formatting in names (#48)
* Changes to use markdown formating. * Update src/Maths/Abs.sol Co-authored-by: David Leal <[email protected]> * Update src/Maths/AliquotSum.sol Co-authored-by: David Leal <[email protected]> * incorporating review suggestions. * Changes to incorporate review comments. Co-authored-by: Max Kubik <[email protected]> Co-authored-by: David Leal <[email protected]>
1 parent bbf4b44 commit 0653099

20 files changed

+1064
-1056
lines changed

src/Maths/Abs.sol

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.0;
3-
4-
/**
5-
* @title Get the absolute value of an integer.
6-
* @author Perelyn https://github.com/Perelyn-sama
7-
* @dev https://www.khanacademy.org/math/cc-sixth-grade-math/cc-6th-negative-number-topic/cc-6th-absolute-value/v/absolute-value-of-integers
8-
*/
9-
contract Abs {
10-
/// Pass in a number and get it's absolute value
11-
function getAbs(int256 _n) public pure returns (int256 result) {
12-
if (_n < 0) {
13-
result = -(_n);
14-
} else {
15-
result = _n;
16-
}
17-
}
18-
}
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
/**
5+
* @title Get the absolute value of an integer.
6+
* @author [Perelyn](https://github.com/Perelyn-sama)
7+
* @dev https://www.khanacademy.org/math/cc-sixth-grade-math/cc-6th-negative-number-topic/cc-6th-absolute-value/v/absolute-value-of-integers
8+
*/
9+
contract Abs {
10+
/// Pass in a number and get it's absolute value
11+
function getAbs(int256 _n) public pure returns (int256 result) {
12+
if (_n < 0) {
13+
result = -(_n);
14+
} else {
15+
result = _n;
16+
}
17+
}
18+
}

src/Maths/AddArray.sol

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.0;
3-
4-
/**
5-
* @title Array Addition.
6-
* @author Anthony (fps) https://github.com/fps8k.
7-
* @dev Contract to demonstrate how an array is added.
8-
*/
9-
10-
contract AddArray {
11-
/**
12-
* @dev Takes in an array of numbers and adds them and returns the cumultative total.
13-
* @param _arr array of numbers
14-
* @return total => sum of array.
15-
*/
16-
function addArr(uint256[] memory _arr) public pure returns (uint256 total) {
17-
/// @dev Initialize the total we need to return to 0.
18-
uint256 sum = 0;
19-
20-
/// @dev Loop through the array.
21-
for (uint256 i = 0; i < _arr.length; i++) {
22-
/// @dev On every element, add the value of the element to the current sum.
23-
/// @dev For sums > the maximum uint value, solidity versions > 0.8.0 will revert on overflow.
24-
sum += _arr[i];
25-
}
26-
27-
/// @dev Return the total.
28-
total = sum;
29-
}
30-
}
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
/**
5+
* @title Array Addition.
6+
* @author [Anthony (fps)](https://github.com/fps8k)
7+
* @dev Contract to demonstrate how an array is added.
8+
*/
9+
10+
contract AddArray {
11+
/**
12+
* @dev Takes in an array of numbers and adds them and returns the cumultative total.
13+
* @param _arr array of numbers
14+
* @return total => sum of array.
15+
*/
16+
function addArr(uint256[] memory _arr) public pure returns (uint256 total) {
17+
/// @dev Initialize the total we need to return to 0.
18+
uint256 sum = 0;
19+
20+
/// @dev Loop through the array.
21+
for (uint256 i = 0; i < _arr.length; i++) {
22+
/// @dev On every element, add the value of the element to the current sum.
23+
/// @dev For sums > the maximum uint value, solidity versions > 0.8.0 will revert on overflow.
24+
sum += _arr[i];
25+
}
26+
27+
/// @dev Return the total.
28+
total = sum;
29+
}
30+
}

src/Maths/AliquotSum.sol

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// SPDX-License-Identifier: MIT
2-
pragma solidity ^0.8.0;
3-
4-
/**
5-
* @title Get the absoule value of an integer.
6-
* @author Perelyn https://github.com/Perelyn-sama
7-
*/
8-
contract AliquotSum {
9-
/// Get the Aliquote sum of a positive integer
10-
function getAliquotSum(uint256 _n) public pure returns (uint256 result) {
11-
for (uint256 i = 1; i < _n - 1; i++) {
12-
_n % i == 0 ? result += i : i;
13-
}
14-
return result;
15-
}
16-
}
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
/**
5+
* @title Get the absoule value of an integer.
6+
* @author [Perelyn](https://github.com/Perelyn-sama)
7+
*/
8+
contract AliquotSum {
9+
/// Get the Aliquote sum of a positive integer
10+
function getAliquotSum(uint256 _n) public pure returns (uint256 result) {
11+
for (uint256 i = 1; i < _n - 1; i++) {
12+
_n % i == 0 ? result += i : i;
13+
}
14+
return result;
15+
}
16+
}

0 commit comments

Comments
 (0)