Skip to content

Instantly share code, notes, and snippets.

@Luna-Klatzer
Last active February 10, 2024 13:21
Show Gist options
  • Save Luna-Klatzer/b16e063e081e55d80081560825c2245d to your computer and use it in GitHub Desktop.
Save Luna-Klatzer/b16e063e081e55d80081560825c2245d to your computer and use it in GitHub Desktop.
Simple Kipper program to get the prime factors of a number
def primeFactors(n: num) -> void {
while (n % 2 == 0) {
print("2");
n /= 2;
}
// For all non-even divisors
for (var i: num = 3; i * i <= n; i += 2) {
while (n % i == 0) {
print(f"{i}");
n /= i;
}
}
// In case the remainder is a prime number > 2
if (n > 2) {
print(f"{n}");
}
}
primeFactors(18);
@Kaede25
Copy link

Kaede25 commented Feb 10, 2024

:D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment