Project Euler/3

From Esolang
Jump to navigation Jump to search

Back to User:ProjectEuler

Project Euler Problem 3 is a problem related to factorization. The problem asks for the largest prime factor of a particular number.

This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

Implementations

Aheui

This program takes the 12-digit constant as input. It works on Try It Online but unfortunately fails on AheuiChem.

방싹박빠삭빠싸사투빠사빠싹삭ㅇ루
ㅇㅇㅇㅇㅇ귀희멍차속누석썩뻐서차수
ㅇㅇㅇ오ㅇㅇㅇㅇㅇㅇ서ㅇㅇ더너벌벌

C

If the program generates an error on your computer, you may try replacing #define lnt long long with #define lnt __int64 or #define lnt __int64_t, and/or replacing %lld with %I64d. [citation needed]

#include <stdio.h>
#define lnt long long
lnt a=600851475143;
lnt i=2;
int main(){
while(a!=i){
if(a%i==0){
a/=i;
}else{
i+=1;
}
}
printf("%lld",i);
return 0;
}

Rockstar

The king was hiding everything, weathering randomly after I went several short millimeters over him.
The state is me
while the king isn't the state.
Let the rule be the king over the state.
Turn it down
if nothing is the king without the rule of the state.
Let the king be over the state,
else
build the state up.


Say the state.

Python

# Euler Problem 3
# by Europe2048
# Fixed by None1

import math
test = int(input("What number do you want to check for? "))
sqrt = math.floor(math.sqrt(test))

prev_primes = []
factors = []
i=2
while i<sqrt:
    flag=1
    while 1:
       flag=0
       for j in prev_primes:
            if i % j == 0:
                flag=1
                break
       if not flag:
           break
       i+=1
    if (test / i) % 1 == 0:
        factors.append(i)
    prev_primes.append(i)
print(factors[-1])

See also

Other pages related to prime factors and factorization:

3 12 21 23

Adjacent numbered pages:

<< < 1 2 3 4 5 6 ... 28 > >>

External resources