Questions tagged [project-euler]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
123 views

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

I defined a,b,c as a=m^2-n^2, ...
Aran's user avatar
  • 363
1 vote
2 answers
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? ...
Aran's user avatar
  • 363
0 votes
1 answer
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 ...
Aran's user avatar
  • 363
4 votes
2 answers
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 ...
A little mouse on the pampas's user avatar
0 votes
1 answer
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 ...
A little mouse on the pampas's user avatar
1 vote
0 answers
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. ...
李子涵's user avatar
  • 316
3 votes
1 answer
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 ...
Lonidard's user avatar
  • 645
1 vote
1 answer
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 ...
babbupandey's user avatar
1 vote
1 answer
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 ...
Anvit's user avatar
  • 131
5 votes
1 answer
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 ...
vapor's user avatar
  • 7,881
8 votes
2 answers
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: ...
vapor's user avatar
  • 7,881
6 votes
2 answers
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 ...
Αλέξανδρος Ζεγγ's user avatar
7 votes
3 answers
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 ...
Manuel --Moe-- G's user avatar
2 votes
0 answers
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 ...
Alexis Purslane's user avatar
2 votes
2 answers
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. ...
user155812's user avatar
7 votes
3 answers
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 '...
user155812's user avatar
2 votes
1 answer
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 ...
Raksha's user avatar
  • 633
4 votes
3 answers
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. ...
HyperGroups's user avatar
  • 8,599
1 vote
1 answer
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: ...
vapor's user avatar
  • 7,881
3 votes
1 answer
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 ...
wuyingddg's user avatar
  • 1,943
14 votes
3 answers
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 [...
globby's user avatar
  • 245
20 votes
4 answers
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: ...
Eric's user avatar
  • 1,191
3 votes
1 answer
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: ...
paw's user avatar
  • 5,650
4 votes
3 answers
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: ...
Borgleader's user avatar
34 votes
8 answers
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: ...
xyz's user avatar
  • 605
4 votes
3 answers
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 ...
expression's user avatar
  • 5,572
3 votes
0 answers
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 ...
RunnyKine's user avatar
  • 33k
0 votes
1 answer
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 ...
Jakob Weisblat's user avatar
5 votes
2 answers
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. ...
Mr.Wizard's user avatar
  • 271k
5 votes
2 answers
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 ...
RunnyKine's user avatar
  • 33k
30 votes
6 answers
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 ...
withparadox2's user avatar
  • 2,481
5 votes
10 answers
2k views

How to find palindromic numbers (Project Euler #4)?

I'm trying to solve the fourth Project Euler's problem with this: ...
Red Banana's user avatar
  • 5,203