freshkitetwenty
Version:
An NPM package solving 20 unique beginner programming problems.
67 lines (46 loc) • 2.62 kB
Markdown
# FreshKiteTwenty
FreshKiteTwenty is an NPM package that provides solutions to 20 beginner-level programming problems. It is designed to help developers practice and enhance their problem-solving skills with simple and efficient JavaScript functions.
## Installation
You can install FreshKiteTwenty using npm:
```sh
npm install freshkitetwenty
```
## Usage
Import the package in your project and use the available functions:
### ES Module (ESM)
```js
import { isPrime, factorial, twoSum } from "freshkitetwenty";
console.log(isPrime(7)); // true
console.log(factorial(5)); // 120
console.log(twoSum([2, 7, 11, 15], 9)); // [0, 1]
```
## Available Functions
The package provides solutions to the following problems:
- **oddOrEven(n)** – Determines if a number is odd or even.
- **swapTwoVariables(a, b)** – Swaps two numbers without using a temporary variable.
- **isLeapYear(n)** – Checks if a given year is a leap year.
- **isBinary(n)** – Checks if a number consists only of 0s and 1s.
- **sumOfDigits(n)** – Computes the sum of digits of a number.
- **factorial(n)** – Finds the factorial of a given number.
- **isPrime(n)** – Checks if a number is prime.
- **fibonacciNumber(n)** – Returns the nth Fibonacci number.
- **isPalindromeNumber(n)** – Checks if a number is a palindrome.
- **isPalindromeString(s)** – Checks if a string is a palindrome.
- **isArmstrongNumber(n)** – Checks if a 3-digit number is an Armstrong number.
- **findGCD(a, b)** – Finds the greatest common divisor (GCD) of two numbers.
- **isPerfectNumber(n)** – Determines if a number is perfect.
- **countDividingDigits(n)** – Counts the digits of a number that evenly divide it.
- **floorSquareRoot(n)** – Finds the square root of a number (floored if not perfect).
- **powerOfReverse(n)** – Computes n raised to the power of its reverse.
- **findMinMax(arr)** – Finds the minimum and maximum elements in an array.
- **findSecondMax(arr)** – Finds the second largest element in an array.
- **countArrayFrequency(arr, n)** – Counts the frequency of numbers in an array (1-based indexing).
- **twoSum(arr, target)** – Returns indices of two numbers that sum up to the target.
## Contributing
Feel free to contribute to this project by opening an issue or submitting a pull request on GitHub.
## License
This project is licensed under the MIT License.
## Author
Created by **Harish Vijendiran student at Freshkite Academy**.
## Links
- [GitHub Repository](https://github.com/HarishVijendiran1997/freshkitetwentynpm)