Tagged Questions
10
votes
6answers
2k views
Beehive numbers - using goto in C++
I understand that using goto in C++ code is strictly unadvised, but sometimes, it really reduces the number of lines of code like in the following case.
This is my ...
7
votes
4answers
412 views
Checking if a number is a perfect square by recursive sum of its digits [closed]
I was solving this question on an online judge.
The problem boils down to the following:
Given a number \$n\$, where \$1 \le n \le 10^{18}\$, we need to check if it contains odd number of ...
6
votes
4answers
729 views
Finding the Pythagorean triplet that sums to 1000
Project Euler problem 9 says:
A Pythagorean triplet is a set of three natural numbers, a < b < c,
for which,
a2 + b2 = c2
For example, 32 + 42 = 9 + 16 = 25 = 52.
There ...
6
votes
5answers
519 views
Improving efficiency of Project Euler 185 (16-place Mastermind)
This a solution for Project Euler Problem 185. It works fine for the example but slow for the problem statement. How can I improve its speed and efficiency?
...
6
votes
2answers
134 views
Helper function to solve Project Euler question 26
Project Euler problem 26 asks us to:
Find the value of d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part.
I wrote this function in Python to find the ...
6
votes
1answer
82 views
Make Project Euler 27 solution idiomatic Ruby
I learned to program in Java and C# and in my free time I am using Ruby because it is fun. Unfortunately I have the feeling that I write Ruby code like I am making Java or C# code. I have learned to ...
4
votes
1answer
712 views
Project Euler Problem 12 - Highly Divisible Triangular Number - Python Solution Optimization
Project Euler Problem 12 asks (paraphrased):
Considering triangular numbers Tn = 1 + 2 + 3 + … + n, what is the first Tn with over 500 divisors? (For example, T7 = 28 has six divisors: 1, 2, 4, ...
3
votes
2answers
58 views
Curious fractions in functional Ruby
Problem 33 in Project Euler asks:
The fraction 49/98 is a curious fraction, as an inexperienced
mathematician in attempting to simplify it may incorrectly believe
that 49/98 = 4/8, which is ...
3
votes
2answers
108 views
Attempting to efficiently compute the largest prime factor
As per the help, here's what I'm looking for from this post: best practice and practical advice about (what I think is describable as) buffering the output of a function.
So I'm working on the third ...
3
votes
1answer
141 views
Truncating an integer from left to right and right to left
Project Euler problem 37 says:
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: ...
1
vote
1answer
167 views
Compute e using Euler's expansion
Given the following task:
Exercise 1.38. In 1737, the Swiss
mathematician Leonhard Euler published
a memoir De Fractionibus Continuis,
which included a continued fraction
expansion for e ...
1
vote
1answer
821 views
Testing if numbers in the array can be added up to equal the largest number in the array
Okay, here's a challenge at Coderbyte that completely stumped me. I came up with a solution, but I know it is flawed.
Have the function ArrayAdditionI(arr) ...