This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findGDC(num1: number, num2: number): number { | |
function calcMod(v1: number, v2: number): number { | |
return v1 % v2; | |
} | |
let a = num1; | |
let b = num2; | |
while (b > 0) { | |
const mod = calcMod(a, b); | |
if (mod === 0) break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isPrime(num: number): boolean { | |
return findFactors(num).length === 2; | |
} | |
function findFactors(num1: number): Array<number> { | |
let factors: Array<number> = []; | |
for (let index = 0; index <= num1; index++) { | |
if (num1 % index == 0) { | |
factors.push(index); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variable to keep track of old value | |
const A: number = 22695477; | |
const B: number = 12820163; | |
const M: number = Math.pow(2, 24); | |
let prev: number = 0; | |
function modGen(val: number, mod: number): number { | |
return val - Math.trunc(val / mod) * mod; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findGDC(num1: number, num2: number): number { | |
function calcMod(v1: number, v2: number): number { | |
return v1 % v2; | |
} | |
let a = num1; | |
let b = num2; | |
while (b > 0) { | |
const mod = calcMod(a, b); | |
if (mod === 0) break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use client"; | |
import React, { useState } from "react"; | |
import { AnimatePresence, motion } from "framer-motion"; | |
import Image from "next/image"; | |
import clsx from "clsx"; | |
type Props = { | |
onPick?: (card: string | null) => void; | |
onSelect?: (card: string) => void; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate unique IDs for use as pseudo-private/protected names. | |
// Similar in concept to | |
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>. | |
// | |
// The goals of this function are twofold: | |
// | |
// * Provide a way to generate a string guaranteed to be unique when compared | |
// to other strings generated by this function. | |
// * Make the string complex enough that it is highly unlikely to be | |
// accidentally duplicated by hand (this is key if you're using `ID` |