prime-factoring Questions

4

I'm trying to solve problem 3 from http://projecteuler.net. However, when I run thing program nothing prints out. What am I doing wrong? Problem: What is the largest prime factor of the number 600...
Hackneyed asked 7/3, 2013 at 18:47

6

Solved

I need to write a program to input a number and output its factorial's prime factorization in the form: 4!=(2^3)*(3^1) 5!=(2^3)*(3^1)*(5^1) The problem is I still can't figure out how to get th...
Valentijn asked 17/1, 2014 at 22:5

4

Solved

I am looking for prime factors of 2500 with the code below, but my code only prints 2 currently and I am unsure why this is the case. no = 2500 count = 0 # Finding factors of 2500 for i in range(...
Mouth asked 2/5, 2014 at 7:32

9

Solved

I'm new to Haskell. How to generate a list of lists which contains prime factors of next integers? Currently, I only know how to generate prime numbers: primes = map head $ iterate (\(x:xs) -&gt...
Hangup asked 22/1, 2014 at 7:35

10

I am trying to find an efficient way to compute Euler's totient function. What is wrong with this code? It doesn't seem to be working. def isPrime(a): return not ( a < 2 or any(a % i == 0 for...

9

I am looking for an implementation or clear algorithm for getting the prime factors of N in either python, pseudocode or anything else well-readable. There are a few requirements/constraints: N is...
Lignin asked 10/1, 2011 at 4:19

6

Solved

Here's my code: def factorize(n): sieve = [True] * (n + 1) for x in range(2, int(len(sieve) ** 0.5) + 1): if sieve[x]: for i in range(x + x, len(sieve), x): sieve[i] = False lowerPrimes = ...

7

I want to create a program in C# 2005 which calculates prime factors of a given input. i want to use the basic and simplest things, no need to create a method for it nor array things etc. just simp...
Wurth asked 3/5, 2011 at 16:58

3

Solved

I'm writing a code in C that returns the number of times a positive integer can be expressed as sums of perfect squares of two positive integers. R(n) is the number of couples (x,y) such that x² +...
Missie asked 6/10, 2012 at 3:6

2

Below is my implementation of Pollard's rho algorithm for prime factorization: #include <vector> #include <queue> #include <gmpxx.h> // Interface to the GMP random number funct...
Looseleaf asked 2/11, 2013 at 12:37

30

Solved

What is the best approach to calculating the largest prime factor of a number? I'm thinking the most efficient would be the following: Find lowest prime number that divides cleanly Check if resu...
Culliton asked 22/8, 2008 at 19:35

3

Solved

It seems that there are several really fast prime factorization algorithms around (one that looks ideal is quadratic sieving). However, rather than make my own (likely poor) implementation I ...
Ez asked 24/5, 2009 at 11:13

3

Solved

The factor command prints the prime factors of specified integer NUMBER. When I tried it factor 12345678912345678912 even for such big numbers, it results within milliseconds. Which algorithm is i...
Gemini asked 22/6, 2012 at 11:29

6

Solved

It's easy enough to make a simple sieve: for (int i=2; i<=N; i++){ if (sieve[i]==0){ cout << i << " is prime" << endl; for (int j = i; j<=N; j+=i){ sieve[j]=1;...
Quadragesimal asked 20/4, 2012 at 15:47

17

Solved

I am trying to implement a function primeFac() that takes as input a positive integer n and returns a list containing all the numbers in the prime factorization of n. I have gotten this far but I ...
Entozoic asked 8/6, 2013 at 4:56

2

While working with the Python primefac module - https://pypi.org/project/primefac/ I noticed that this code works: import sys import primefac n = 600851475143 factors = list(primefac.primefac(n...
Jarvisjary asked 18/1, 2019 at 12:0

12

Solved

#include <iostream> using namespace std; void whosprime(long long x) { bool imPrime = true; for(int i = 1; i <= x; i++) { for(int z = 2; z <= x; z++) { if((i != z) && (i...
Immediately asked 12/8, 2012 at 17:28

8

Solved

Regular numbers are numbers that evenly divide powers of 60. As an example, 602 = 3600 = 48 × 75, so both 48 and 75 are divisors of a power of 60. Thus, they are also regular numbers. This is a...
Bespatter asked 11/2, 2012 at 18:16

6

I've been working on a little problem where I need to compute 18-digit numbers into their respective prime factorization. Everything compiles and it runs just fine, considering that it actually wor...
Granados asked 13/10, 2014 at 15:54

2

Solved

Given a number 1 <= n <= 10^18, how can I factorise it in least time complexity? There are many posts on the internet addressing how you can find prime factors but none of them (at least fro...

12

Solved

I'm doing this problem on a site that I found (project Euler), and there is a question that involves finding the largest prime factor of a number. My solution fails at really large numbers so I was...
Freeway asked 11/6, 2014 at 15:9

3

Solved

isqrt :: Integer -> Integer isqrt = floor . sqrt . fromIntegral primes :: [Integer] primes = sieve [2..] where sieve (p:ps) = p : sieve [x | x <- ps, x `mod` p > 0] primeFactors :: Inte...

6

Solved

My understanding is that many public key cryptographic algorithms these days depend on large prime numbers to make up the keys, and it is the difficulty in factoring the product of two primes that ...

5

Solved

I am currently trying to incorporate the Stream API of Java 8 into my everyday Java toolbox. I am trying to use Streams to find the prime factors of a positive integer, and then store each of the f...
Correy asked 13/3, 2016 at 5:0

1

Solved

I've been writing a simple program in python that encodes a string into a number using Gödel's encoding. Here's a quick overview: you take the first letter of the string, find its position in the a...
Tart asked 31/12, 2015 at 14:28

© 2022 - 2024 — McMap. All rights reserved.