Questions tagged [project-euler]

Use this tag for questions that came from the Project Euler website.

32 questions
Filter by
Sorted by
Tagged with
123 views

How could this Project euler question be written in mathematica? [closed]

I defined a,b,c as a=m^2-n^2, ...
• 363
1 vote
107 views

What would be another way to write this code in mathematica

What would be another way to write this code in mathematica,but without using the code for and if? Is integer digits necessary foor this type of code? ...
• 363
165 views

How do we find how many values for a Smooth square root?

this question is from the Eulers project The positive integer is called square root smooth if all of the prime factors it has are less than its square root. Including the number 1, there are 29 square ...
• 363
1k views

How to solve this problem 710 of Project-Euler

I want to solve this problem: The number 6 can be written as a palindromic sum in exactly eight different ways: (1,1,1,1,1,1),(1,1,2,1,1),(1,2,2,1),(1,4,1),(2,1,1,2),(2,2,2),(3,3),(6) We shall define ...
180 views

How to solve problem 599 of Project-Euler

Problem 599 of the Project-Euler is described as follows: The well-known Rubik's Cube puzzle has many fascinating mathematical properties. The 2×2×2 variant has 8 cubelets with a total of 24 visible ...
1 vote
107 views

Integer linear programming can't find global minimum

I was working with Project Euler Problem 418 using Mathematica and got in trouble. I wrote a function to find the unique factorization triple which minimizes c / a for integer n. ...
• 316
342 views

Generation of Step Numbers

I am working on Project Euler 178 but got stuck in trying to optimize my code. The following text comes from the problem: Consider the number $45656$. It can be seen that each pair of ...
• 645
1 vote
236 views

How to loop through a large number in mathematica

I am trying to find all divisors of 200! [Project Euler, problem 608 - in case anybody is curious]. It has many divisors and hence using ...
• 161
1 vote
75 views

Converting sequece of code into a function [closed]

I constructed a pretty basic sieve of Eratosthenes and would like to use it as a function rather than copy pasting output, how do I achieve ...
• 131
311 views

How to simulate a Disk operation in a good way?

I want to simulate an operation on a disk, originally specified in project-euler problem #566. Here is a description of the problem. I want to simulate a disk with arbitrary partitions, but only two ...
• 7,881
198 views

How to implement this simple procedural style algorithm efficiently in Mathematica style code?

I am trying to move my C solution code for project euler problem 135 to Mathematica. But I encountered serious performance problem. The algorithm is very simple, here is a plain translation: ...
• 7,881
739 views

Euler Project Problem 18

I use Mathematica to implement a function, which output the position path in the triangle required. And the elements are found to be {75, 95, 47, 87, 82, 75, 73, 28, 83, 47, 43, 73, 91, 67, 98}, which ...
• 9,733
228 views

Counting runs in bits, along with their starts and lengths, in functional style

Here is some code to visualize Project Euler Problem 502. The code scans for runs of bits in the binary representation of an integer, and outputs the beginning position of each run and the length of ...
• 1,057
89 views

Why does this function recur forever? [closed]

I am trying to solve Project Euler Problem 31, but I don't want answers for that. I just want to know why this function recurs forever. It just keeps subtracting one forever, on the ones where it goes ...
392 views

How to Optimize Solution? (Project Euler #14) [duplicate]

Link to Question: https://projecteuler.net/problem=14 I began by defining the following functions below. ...
• 505
795 views

Copy/Pasting a Grid of Numbers from Project Euler

On Project Euler Problem 11 (link: https://projecteuler.net/problem=11), there is a 20x20 grid of numbers. However, when I pasted it into Mathematica, I got this strange result where the times symbol '...
• 505
269 views

Integer partitions and dice result probabilities

This is a Project Euler question, so no spoilers :] I was going to try to solve it by first finding how many ways a certain sum can be acquired from a number of dice using ...
• 633
340 views

The usage of MapIndexed, can it be removed?

project euler 67 When I'm solving this problem, my solution is as following. You can download the data file there. ...
• 8,599
1 vote
943 views

Code efficiency improvement needed solving problem 499 in Project Euler

I am trying to solve https://projecteuler.net/problem=499 by constructing a transition matrix and finding its steady state. Here is my code: ...
• 7,881
217 views

How to speed up my code about Divisors?

This code is about PE496 In[21]:= ParallelSum[n*Count[Divisors[n^2], a_ /; n < a < 2 n], {n, 1, 10^5}] // AbsoluteTiming Out[21]= {5.987342,10724527832} I ...
• 1,943
2k views

Collatz optimization

I'm VERY new to Mathematica programming (and by new I mean two days), and was solving Project Euler question 12, which states: Which starting number, under one million, produces the longest [...
• 245
3k views

How to speed up my Project Euler code

The evaluation speed of Mathematica often depresses me. It did it again when I wrote a code to solve a Project Euler problem. https://projecteuler.net/problem=206 Here's my code: ...
• 1,191
425 views

Performance of compiled functions (Project Euler No14)

I was playing around with the project euler problem 14. The solution I came up with is listed below as cf1. The solution works fine but I get the compiler warning: ...
• 5,650
673 views

Why is my solution to PE #5 so slow

I'm new to Mathematica and it was suggested to me to go through the Project Euler problems in order to learn it. However, I can't quite figure out why my solution to #5 is so slow. The problem: ...
• 143
36k views

Even Fibonacci numbers

Today, I found the Euler Project. Problem #2 is Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: ...
• 605
592 views

Improve the performance of solutions to Project Euler (#14)

Problem I have following code, when n<=10^5 it's not slow, but n>2*10^5 it's became very slow. I think maybe some temp value greater than 2^31-1, so make compile invalid. Could you give any idea ...
• 5,572
383 views

Project Euler (memory and speed issues)

Let n be a positive integer. An integer triple (a, b, c) is called a factorisation triple of n if: 1 ≤ a ≤ b ≤ c a·b·c = n. Define f(n) to be a + b + c for the factorisation triple (a, b, c) of n ...
• 33k
151 views

Strange function definition result [duplicate]

I'm relatively new to Mathematica, and I'm trying to define a function f(k) that would do the following: For any positive integer $k$, a finite sequence $a_i$ of fractions $\frac{x_i}{y_i}$ is ...
472 views

How can this DivisorSigma code be made fast?

Since Project Euler problems are now fair game for questions I have a question of my own. A certain problem* states: For a positive integer n, let σ2(n) be the sum of the squares of its divisors. ...
• 271k
625 views

Improve performance and style of solution to Project Euler #32

Since I'm fairly new to Mathematica, I'm trying to learn better ways to improve my coding skills so I've turned to Project Euler and this site to speed up my learning pace. Anyways, I was trying to ...
• 33k
3k views

How to improve the performance of solutions to Project Euler (#39)?

This is the problem 39 of Project Euler, which I asked in the chat room two days ago. My original code runs as slowly as snails, and finally I got two answers from JM and Rojo. Unfortunately, both of ...
• 2,481