2
votes
1answer
878 views

What is the time complexity of the algorithm to check if a number is prime?

What is the time complexity of the algorithm to check if a number is prime? This is the algorithm : bool isPrime(int number){ if(number < 2) return false; if(number == 2) return true; if(number ...
0
votes
2answers
221 views

Algorithm for picking reasonable min/max vals given a single value

I am making a simplistic in-browser IDE for some very domain-specific coding. Because I like Bret Victor's thoughts on Learnable Programming so much I thought I'd throw in some draggable numbers ala ...
2
votes
1answer
262 views

Filling array with numbers from given range so that sum of adjacent numbers is square number

Problem: Fill all the cells using distinct numbers from <1,25> set, so that sum of two adjacent cells is a square number. (source: http://grymat.im.pwr.wroc.pl/etap1/zad1etp1213.pdf; numbers 20 ...
12
votes
8answers
2k views

Find a “hole” in a list of numbers

What is the fastest way to find the first (smallest) integer that doesn't exist in a given list of unsorted integers (and that is greater than the list's smallest value)? My primitive approach is ...