project-euler

Computing A Specific Generating Function Sequence

http://www.research.att.com/~njas/sequences/A097196 I was wondering how to continue generating the sequence given in the link. It is based off a generating function. Any ideas would be appreciated. Certain numbers in a certain sequence of this sequence are showing up as answers to subproblems of Project Euler problem 208 (robot walks...

Project Euler for programmers?

Duplicate: Websites like projecteuler.net I really like the Project Euler website but its emphasis seems to be more on math than programming. While solutions are given in code, the most efficient tend to rely on knowledge of different areas of math. Is there anything similar that is oriented towards programmers? For (a dumb) examp...

Haskell script running out of space

I'm using project Euler to teach myself Haskell, and I'm having some trouble reasoning about how my code is being executed by haskell. The second problem has me computing the sum of all even Fibonacci numbers up to 4 million. My script looks like this: fibs :: [Integer] fibs = 1 : 2 : [ a+b | (a,b) <- zip fibs (tail fibs)] evens :: I...

Project Euler problem 214, How can i make it more efficient?

I am becoming more and more addicted to the Project Euler problems. However since one week I am stuck with the #214. Here is a short version of the problem: PHI() is Euler's totient function, i.e. for any given integer n, PHI(n)=numbers of k<=n for which gcd(k,n)=1. We can iterate PHI() to create a chain. For example starting from 18: ...

Need help solving Project Euler problem 200

I am trying to formulate an algorithm to solve Project Euler's Problem 200. We shall define a sqube to be a number of the form, p2q3, where p and q are distinct primes. For example, 200 = 5223 or 120072949 = 232613. The first five squbes are 72, 108, 200, 392, and 500. Interestingly, 200 is also the first number f...

High precision integer math in C#?

Hi, I have a very large number I need to calculate, and none of the inbuilt datatypes in C# can handle such a large number. Basicly I want to solve this: Project Euler 16: 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? I have already written the code...

Problem in understanding problem 31 of Project Euler?

Hi, Could anyone please explain me problem 31 of project euler more clearly please. My English is not good, I really don't understand problem clearly. Is the problem saying to calculate the coins in any order like: 2*£1 or perhaps 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p Thanks in advance for your time and suggestion. ...

Weird Powershell performance issue

NOTE: This is a solution for Project Euler problem 14. If you still want to solve it yourself then don't read on. The problem was to find the number below one million which, as starting number for the Collatz sequence, produces the longest such sequence. My initial code was as follows: $r = @{} for($i = 1; $i -lt 1000000; $i++) { ...

Project Euler Problem 245

I'm onto problem 245 now but have hit some problems. I've done some work on it already but don't feel I've made any real steps towards solving it. Here's what I've got so far: We need to find n=ab with a and b positive integers. We can also assume gcd(a, b) = 1 without loss of generality and thus phi(n) = phi(ab) = phi(a)phi(b). We are...

Overcoming heap overflow issues

After taking a single Computer Science course last semester, I've been attempting to improve my coding abilities by trying to solve problems from Project Euler. I know my method would work logically(it returns answers to the small scale problem almost instantly). However, it scales horribly. If anyone could help me develop a better appro...

Dividing in an if statement

In Python, if I had a range, and I wanted to iterate over it and divide each number by another number, could I do that in a if statement. a = range(20) for i in a: if i / 3 == True: print i ...

Project Eulers problem 16 in visual basic. Sum of digits in the number 2^1000

Project Euler's problem 16: 2^(15) = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^(1000)? I have been trying to do this problem for a few days now and i just can't figure out how to get vb.net 2008 to recognize anywhere near that large a number. I have seen in other posts that...

Help with Project Euler #200?

Possible Duplicate: Need help solving Project Euler problem 200 Similar to this question Project Euler Problem 200. I wrote up a brute force solution in Java that takes several hours to run, and produced the first 500+ sqube numbers, which I thought should be enough. However, none of the answers from 190 to 210 seems to be...

simple C problem

Hi, I have had to start to learning C as part of a project that I am doing. I have started doing the 'euler' problems in it and am having trouble with the first one. I have to find the sum of all multiples of 3 or 5 below 1000. Could someone please help me. Thanks. #include<stdio.h> int start; int sum; int main() { while (start < 1...

Is using goto a legitimate way to break out of two loops?

I am solving problem 9 on the Project Euler. In my solution I use a "goto" statement to break out of two for loops. The Problem is the following: A Pythagorean triplet is a set of three natural numbers, a b c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean t...

Really Big Numbers and Objective-C

I've been toying around with some Project Euler problems and naturally am running into a lot that require the handling of bigger than long long type numbers. I am committed to using Cocoa and Objective-C (I need to stay sharp for work) but can't find an elegant way (read: library) to handle these really big numbers. I'd love to use GMP...

Best bignum library to solve Project Euler problems in C++ ?

Hi, I am still a student, and I find project Euler very fun. sometimes the question requires calculations that are bigger than primitive types. I know you can implement it but I am too lazy to do this, So I tried few libraries, MAPM :: very good performance, but it provides only big floats, with the possibility to check if it is an i...

PHP function efficiencies

Hi, Is there a table of how much "work" it takes to execute a given function in PHP? I'm not a compsci major, so I don't have maybe the formal background to know that "oh yeah, strings take longer to work with than integers" or anything like that. Are all steps/lines in a program created equal? I just don't even know where to start rese...

Determing longest repeating cycle in a decimal expansion

Today I encountered this article about decimal expansion and I was instantaneously inspired to rework my solution on Project Euler Problem 26 to include this new knowledge of math for a more effecient solution (no brute forcing). In short the problem is to find the value of d ranging 1-1000 that would maximize the length of the repeating...

Get all factors of a number (iterators showdown :)

You are given all the prime factors of a number, along with their multiplicities (highest powers). The requirment is to produce all the factors of that number. Let me give an example: Prime factors: 2 (power: 3) 3 (power: 1) (meaning the number is 2^3 * 3^1 = 24) The expected result is: 1, 2, 3, 4, 6, 8, 12, 24 I'm thinking of d...