-
Sieve of Eratosthenes In mathematics, the sieve of Eratosthenes is a simple, ancient algorithm for finding all prime numbers up to any given limit.
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
The algorithm consists of creating a list of consecutive integers from 2 through n (2 <= n <= 2^64) and marking them off as prime (or composite)
Implement this algorithm in Javascript or TyeScript as a function
sieveOfEratosthenes(n: number)
that returns an array of all prime numbers up to (and including)n
. -
Least Common Multiple In mathematics, the least common multiple (LCM) of two or more integers is the smallest positive integer that is divisible by each of the given integers.
For example, the LCM of 4 and 6 is 12.
Implement this algorithm in Javascript or TyeScript as a function
leastCommonMultiple(n1: number, n2: number)
that takes two integers returns the LCM of the given integers. -
Palindrome A palindrome is any string that can be reversed and still be the same. An example of one is 'radar', since it is spelled the same even after being reversed.
Implement this algorithm in Javascript or TyeScript as a function
palindrome(str: string)
that takes a string and returns true if the string is a palindrome.
mainamary / assignment-dsa Goto Github PK
View Code? Open in Web Editor NEWHands on practice on data structures and algorithims