In my line of work I often have the task of determining equidistant spacing of series of objects, e.g. mullions in a window frame or piers in a colonnade, in such a way that the result is dimensionable on a drawing in whole millimetres (or multiples of ten, depending on the scale-order of design). This
usually entails seeing what will go into a total dimension like the width of a window less one mullion thickness, and if my chosen mullion thickness is something like 57mm there is a fair chance that the total comes to a prime number.

It would save me a lot of fruitless speculation if I could simply enter the total on my calculator and get a yea or nay as regards whether or not it is a prime number. It would be better if I could also get a run-down of possible factors, e.g. 629 would return 37 17; 637 would return 19 7; 660 would return 11 5 4 3 2; 37 would return P.

Prime number checkerhttp://www.math.com...ce/prime-number.htm This should solve your problem. It's Javascript and tends to get rather slow if you enter big numbers. [marklar, Nov 27 2007]

Calculating primes is extremely hard, compared to other operations. There have only relatively recently been advances algorithms to find primes, and they work on the probability of a number being a prime, which is not what you want.

In order to test a prime, you have to test it against all primes of a lower value, which of course is fine for any of the numbers you mentioned and anything up to about 10 digits should be no problem for a normal calculator.

The engineering solution is to use preferred numbers and insist on suppliers who have products which use preferred numbers. That way your problems get very neatly solved...

The problem, [vincevincevince], is that different industries have different series of preferred numbers, and it's my job to get them to work together.

From your link: "In the construction industry, it was felt that typical dimensions must be easy to use in mental arithmetic." I am therefore reluctant to tell a contractor to build columns at 3627mm centres. Because there is a sort of "customary tacit tolerance" in the building industry I can't police a dimension like that the way I can a dimension of 3600mm. Nor can I verify that drawings done by subordinates are correct without doing a lot of math. I consequently spend a lot of time finding rhythms that allow both regular spacings and sensible dimensions.

A factorization facility would make that a lot simpler, and a prime-number alert would warn me not to pursue impossibilities.

That preferred number stuff is interesting. Another reminder that the making of buildings is rather tricky, a fact I am reminded of daily.

By-the-by, if anyone finds the body of a Romanian contractor floating in the Thames tomorrow, is has nothing to do with the continuing non-arrival of my glass balustrade.

[wagster], the first rule is, never programme a construction process so that it'll be done by Christmas. November is not a time to fit balustrades. November is a time to fit first-fix plumbing and electrics. Your solution is called February. Take a deep breath, sigh a bit if you want, and embrace it.

...but you also have to consider with width of the mullions so that you can specify glass to be cut in sensible dimensions don't you? I recently had a similar problem in which wanted to hang two similarly-sized pictures on a wall such that the gap between the two pictures was the same as the gaps between the pictures and the ends of the wall - you have to place the hooks (width of picture/2) + ((width of wall - (2*width of picture))/3) from the ends of the wall...

There could be a ROM chip storing a sieve of Erastosthenes for integers up to a certain level as single-bit flags. The operand could be used as an address.

A prime? button would be of use to me even without factorization. I get an odd number that doesn't end in 5, and the sum of whose whose digits is not divisible by 3. Do I bother looking for sensible factors? Or do I rather redesign so the total is 10mm more or 10mm less?

What [nineteently] said. About the erastophanes operands 'n stuff.

[Ned] - the builders leave today - it's all done, right down to the houseplants and the bedding that matches the wallpaper. But you can still fall two stories out of the bedrooms.

There's also something about only having to search up to the square root of an integer which apparently simplifies things, but i can't remember it. Also, the ROM could fit in twice as many numbers if all the even ones were missed out and the result was shifted one bit to the left afterwards, with the proviso that the number two was returned from the function as true automatically, so:

If x=2 then set flag to true and exit;
If x is even then set flag to false and exit;
Increment x;
Shift x right one bit, look it up in the ROM, then return the bit at the appropriate address.

I wrote "factor finder" in Applesoft many years ago. Iterations are so fast now that this would not be hard to do with brute force, especially in smaller numbers such as those used in construction. I am not sure if calculators have the ability to do something like this, but it certainly could be done using basic or even an excel spreadhseet, if a laptop is handy.

But maybe a guy called Ned_Ludd is intolerant of laptops. I am not sure if a slide rule can be used to find factors.

It seems to me that the idea of "prime"-ness is a purely digital creation. If you want something divided into n segments, draw n segments on a piece of paper, put it in a projector, and adjust it to subtend the distance you wanted to divide. There's your segments. O'course, the gods of small close-fitted stones may inadequately defend you if you try to pass the resultant measure off on a vendor.