You are not logged in.
I am solving a daily math problem it's asking:
How many integers between 1 and 999 have 3 divisors?
I'm not sure where to start with this. I don't think there's a systematic way to find how many have 3 divisors
I also don't think there is a way to use algebra for this
Could anyone give advice on where to start. I'm kind of stumped.
on a journey to solve interesting problems
Offline
hi kittenlover206
There is a way to answer this without checking every single integer.
Except for 1, all numbers have at least two divisors, 1 and the number itself.
If a number has another then mostly it will have another. If f is a divisor of N then N/f is another divisor. eg. 48 has these divisor pairs {1, 48, 2, 24, 3, 16, 4, 12, 6, 8}
So we can divide the integers into sets like this.
{1} has a single divisor.
{primes} have 2 divisors. eg divisors of 7 = {1,7}
{many non primes} have an even number of divisors: 1, the number, one or more divisors f, and another N/f for each f. (Such as 48 see above)
So what integers have an odd number of divisors? From these which have only one extra apart from 1 and the number?
Bob
Children are not defined by school ...........The Fonz
You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you! …………….Bob
Offline
Hi Bob,
Using a method similar to Bob's:
#Each number will have at least 2 divisors except th no. 1
#There are 999 numbers.
#If we count from 4 as 1,2,3 are exceptions (being first 3 nos), there will be total 999-4+1=996 numbers.
# Out of 996, 1/2 will be even. So there are 492 even nos.
# Even numbers have at least 3 divisors {1,2…the no.}. So 492 nos have 3 divisors. Point no. 1
#Remaining 492 nos are odd. Some of them are primes. Count the number of primes except 1,2,3 and subtract the number from 492 as non primes will have any divisors other than 1,2.
#Add the result in 492 and you might get an approx answer.
Or,
You can directly subtract the number of primes from 996. I guess it might provide similar result.
This might work.
Last edited by ktesla39 (2025-01-20 02:10:36)
"Talent hits the target no one else can hit. Genius hits the target no one else can see." - Arthur Schopenhauer
Offline
Thanks for the advice guys
I didn't think about the prime number thing haha, I was able to come up with something after that
So I think the answer is realising squares of prime numbers have three divisors, to find how many there are find all prime numbers below 999 square rooted
This should be up to 961 which was 31 squared
If I count this I get 11 prime numbers
I think this is right.
on a journey to solve interesting problems
Offline
Okay
I'll try python or JS automation to solve the question by dividing all integers from 1-999.
Bye for now as I'm going to join my classes.
"Talent hits the target no one else can hit. Genius hits the target no one else can see." - Arthur Schopenhauer
Offline
Hi ktesla39,
I'll try python or JS automation to solve the question by dividing all integers from 1-999.
Good idea...I tried it with Mathematica, and here's my code and solution:
It tested all integers in that range, and for each integer that had only 3 divisors it printed the solution number, the integer number, and the divisors. When done, it gave the total number of solutions.
Last edited by phrontister (Yesterday 13:27:39)
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Offline
So I think the answer is realising squares of prime numbers have three divisors, to find how many there are find all prime numbers below 999
That's exactly what I was hoping you would realise.
Well done! And that's my answer too.
Bob
Children are not defined by school ...........The Fonz
You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you! …………….Bob
Offline
Oh,
I misunderstood the question!
I thout we had to count the numbers having atleast 3 divisors.
Sorry for that.
"Talent hits the target no one else can hit. Genius hits the target no one else can see." - Arthur Schopenhauer
Offline
Hi ktesla39,
I'll try python or JS automation to solve the question by dividing all integers from 1-999.
Good idea...I tried it with Mathematica, and here's my code and solution:
It tested all integers in that range, and for each integer that had only 3 divisors it printed the solution number, the integer number, and the divisors. When done, it gave the total number of solutions.
Hi
By the way, which language did you use in that program? It looks like python, is it?
"Talent hits the target no one else can hit. Genius hits the target no one else can see." - Arthur Schopenhauer
Offline
Hi ktesla39;
By the way, which language did you use in that program? It looks like python, is it?
No, it's not Python.
Mathematica has its own [proprietary] language, and you need to have the program (not free) to run the code.
I only have a basic knowledge of programming in it, as any Mathematica coder would quickly see if they saw my code.
I'm more familiar with BASIC, and was able to use some of that knowledge in Mathematica, which can run adjusted BASIC-like code, but with reduced efficiency compared to its own language.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Offline
Oh
I never used big bracs in any code. That's why I was asking. My JS code was:
<script>
m = 1
count = 0
for (i=0;i<1000;i++) {
for (n=0;n<i;n++) {
if (i % n == 0) m += 1;
if (n == i && m==3) {
count += 1;
document.write(i +"<br>")
}
}
}
document.write("The numbers with 3 divisors are mentioned above<br> There are " +count +"numbers from 1 to 1000 having 3 divisors")
</script>
I guess this might work. This code is in JS and also needs HTML to be set up.
"Talent hits the target no one else can hit. Genius hits the target no one else can see." - Arthur Schopenhauer
Offline
Hi ktesla39;
I revised my code to be much more Mathematica-like:
Code:
Length[Cases[Table[Divisors[i++],{i,999}],{_,_,_}]]
Output:
11
Last edited by phrontister (Yesterday 20:20:25)
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Offline
Now it's out of my mind.
Do you study about computer science?
Last edited by ktesla39 (Yesterday 01:37:53)
"Talent hits the target no one else can hit. Genius hits the target no one else can see." - Arthur Schopenhauer
Offline
Do you study about computer science?
No, not at all.
I just love doing number puzzles, with or without computer aided software.
For me, tackling a challenging number puzzle is simply a nice way to relax.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson
Offline
Ya I also like puzzles and complex things a lot.
"Talent hits the target no one else can hit. Genius hits the target no one else can see." - Arthur Schopenhauer
Offline