The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add comment
Steven Tey2ea6415ef8a4
diff --git a/apps/web/ui/charts/utils.ts b/apps/web/ui/charts/utils.tsindex 8294bcac21..ab02903fe0 100644--- a/apps/web/ui/charts/utils.ts+++ b/apps/web/ui/charts/utils.ts@@ -1,5 +1,19 @@/**- * Finds all whole factors of a number+ * Calculates and returns all whole factors of a given positive integer.+ * A factor of a number is a whole number that can be divided evenly into the number,+ * meaning without leaving a remainder. This function efficiently generates a list of+ * such factors for any given positive integer by iterating through all possible+ * candidates (from 1 to the number itself) and checking divisibility.+ *+ * @param {number} number - The positive integer for which to find all whole factors.+ * It should be a non-negative integer, as negative numbers+ * and non-integers are not handled by this function.+ * @returns {number[]} An array of numbers representing all the whole factors of+ * the input number, including 1 and the number itself if applicable.+ *+ * Example usage:+ * getFactors(12); // returns [1, 2, 3, 4, 6, 12]+ * getFactors(7); // returns [1, 7]*/-export const getFactors = (number) =>+export const getFactors = (number: number) =>[...Array(number + 1).keys()].filter((i) => number % i === 0);