Given two natural numbers

lo<hi, find a triple (a,b,c) such thatais coprime tob,bis coprime toc, andaisnotcoprime toc, or indicate that no such triple exists. If there is more than one such triple, you may return any of them. Two numbers are coprime if their greatest common divisor is 1.Loandhiwill be less than 10^{18}and differ by no more than 50.

Your task is to find a triple satisfying the conditions above. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>Although most of my readers are accomplished, savvy programmers, (or at least those who are confident enough to comment) I will always include content designed for beginners; it’s part of the DNA of the blog, and sometimes brings in new readers. Thus, I spend a lot of time in beginner-programmer online forums. Today’s question at Reddit caught my eye:

Newbie question: What’s the difference between a “loop” and a “function”?Sorry if this is answered somewhere but I am completely new to programming.

What is the difference between a function and a loop, when both of them can be used more than once?

The posting history of the person who asked that question indicates that he has recently been expelled from college (his GPA wasn’t great) and that

In the meantime I just started a computer programming course online. Was never really interested in it but everyone says it’s a skill you should have so I figured I’ll give it a shot. Plus it’s free so there’s that.

Your task is to answer the newbie question; if you answer on Reddit, please also leave your answer here, with a pointer to your Reddit posting. When you are finished, you are welcome to read my answer or discuss the exercise in the comments below.

]]>Your task is to solve the two array search problems described above. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>Given a range of non-negative integers, count the number of 2s, 5s and 8s in the decimal representations of the digits. For instance, from 295 to 305, there are 9:

295: 2 296: 1 297: 1 298: 2 299: 1 300: 0 301: 0 302: 1 303: 0 304: 0 305: 1 Total 9

Your task is to write a program to count the 2, 5, and 8 digits in the range of integers. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>A *set* is an unordered collection of elements, and supports two operations: add an element, and delete an element. A *set without replacement* is a set where an element, once deleted from the set, cannot later be added back into the set.

Your task is to implement sets without replacement. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>Your task is to write a program that calculates the first *n* members of the pentabonacci sequence and determine the rule that states whether the *n*th member of the sequence is even or odd. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Your task is to calculate the pseudoprimes to bases 2 and 3 less than a million. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>Your task is to find all the Muenchhausen numbers in radix-10. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>Your task is to write a useful program using only a single line of code. When you are finished, you are welcome to read a suggested solution, or to post your own solution or discuss the exercise in the comments below.

]]>