[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
I AM HERE TO KILL QUICK WRITE A PROGRAM THAT FINDS THE SMALLEST
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 75
Thread images: 9
File: 1467871737890.jpg (46 KB, 408x426) Image search: [Google]
1467871737890.jpg
46 KB, 408x426
I AM HERE TO KILL
QUICK WRITE A PROGRAM THAT FINDS THE SMALLEST NUMBER WITH 2^500500 DIVISORS AND OUTPUT number%500700
START CODING MA/G/GOTS
>>
did japamoot kill >>>/prog/ ?
>>
>>55470613
That's a big number
>>
>>55470616
>>55470630
STABBY STABBY
START WORKING
>>
File: 1467873573463.jpg (27 KB, 412x430) Image search: [Google]
1467873573463.jpg
27 KB, 412x430
My stabby bird is gonna fite yours
1v1 de_dust n00b
>>
But the smallest (positive) number with X divisors is and will always be 1. This program has no meaning.
>>
>>55470613
puts 1%500700
>>
>>55470613
pickle pee
>>
>>55470723
>>55470735
>>55470737
YOU ARE GOING TO DIE
120 IS THE SMALLEST NUMBER WITH 16 DIVISORS
1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 24, 30, 40, 60, 120
>>
>>55470745
Actually, 1 is
>>
>>55470756
CS MAJORS ARE KILL
1 IS DIVISOR OF ALL NUMBERS, BUT THAT DOES NOT MEANS IT HAVE INFINITE NUMBER OF DIVISORS ITSELF
>>
>>55470745
1 / 1 / 1 / 1 / 1 / 1 ................. = 1

This is what happens when you're a script kiddie trying to steal OP's thread idea.
>>
>>55470613
print 2 ** (2 ** 500500 - 1) % 500700

:^)
>>
>>55470745
It's 1.
What you are looking for is distinct factors
>>
>>55470783
It's actually 0, because he didn't say it should have only 16 divisors.
>>
>>55470775
you can literally divide 1 by anything :)
>>
>>55470803
>macfag
>pink
yup, checks out
>>
>>55470613
>homework thread
An hero, imposter crow. :^)
>>
>>55470807
i don't have a mac
>>
>>55470803
GOPNIK EDUCATION
>>55470803
>>55470783
>>55470777

>For integers m and n, it is said that m divides n, m is a divisor of n, or n is a multiple of m, and this is written as m|n,
if there exists an integer k such that mk=n
>>
REAL THREAD

>>55452571
>>55452571
>>55452571
>>55452571

Op always provides a reference answer himself. This guy here is an impostor.
>>
File: Capture.png (22 KB, 580x320) Image search: [Google]
Capture.png
22 KB, 580x320
>>55470835
I still haven't found a solution
>>
File: def.png (27 KB, 742x229) Image search: [Google]
def.png
27 KB, 742x229
>>55470796
I dunno man. Wolfram definition doesn't have the second constraint, but I wanted to be sure.
>>
>>55470828
>if there exists an integer k such that mk=n
If only I could solve 1*k=1, then I could prove that a k exists. Damn
>>
>>55470849
>I havent found a solution
>Btw, I also edited the html :*)
>>
>>55470910
Good luck editing the red line from 4 chan x
>>
>>55470803
go home daniel
>>
>>55470656
I can't wait for /v/ to leave.
>>
>>55470613
uh, is it
print(0);
?
>>
>>55472594
YOU BETTER CAN INTO MATH OR I AM COMING FOR YOU
>>
File: 23.jpg (42 KB, 600x606) Image search: [Google]
23.jpg
42 KB, 600x606
I'VE HAD ENOUGH OF YOU STUPID BIRD
>>
>>55470613
print "0"
>>
Wait a minute, bird-kun, wouldn't the smallest number be negative infinite?
>>
>>55473318
POSITIVES ONLY
>>
>>55473666
>Prime
>Number with 2^500500 divisors?!?!
THE MODULO IS A GIVEAWAY
>>55470613
YOU CAN USE MODULO 500500507 IF YOUR LANGUAGE CAN'T USE BIG NUMBERS
>>
>>55470613
ruby wins suck it python fags
require 'prime'
puts Prime.take(500500).reduce(&:*).modulo(500700)
>>
>>55470613
print 0
>>
>>55474117
>>55473170
>>55470796
>>55470783
>>55470777
>>55470756
>>55470735
>>55470723
CS MAJORS ARE GOING TO GET STABBED
/G/ IS KILL ON THE FIRST PROBLEM THAT REQUIRES SOME MATH
>>
So 2 hast two divisors, 1 and 2. 2^2 has 3: 1, 2 and 4. So the power of two with 500500 divisors is 2^500499. This should be the smallest, since other factors would only make it bigger.

We can also conclude that 2^19 < 500700 < 2^21. After that I'm stuck.
>>
>>55474242
And yeah, the factorisation of 500700 is 2^2, 3, 5^2 and 1669
>>
>>55473778
>require
topcuck
>>
>>55474242
Nope, you can find the number of divisor of a number by using Euler's totient function
>https://en.wikipedia.org/wiki/Euler%27s_totient_function
>>
>>55474281
cuck
>>
>>55470835
Not true, I just checked the archives on all stabby bird threads, only the "nines array" one has OP posted a solution in the first post
>>
>>55474716
The totient function counts the numbers coprime to n, not the ones indivisible by n. 4 and 6 are neither coprime nor divisors of each other. Nevertheless, there is a formula for the number of divisors. If you decompose n into the product of powers of primes p_i with exponents a_i, the number of divisors of n is the product of all a_i + 1.
https://en.wikipedia.org/wiki/Divisor_function#Properties

Then the task is to minimize 2^a_1 * 3^a_2 * ... * p_n^a_n (since the number of divisors is independent of the primes chosen, they can be chosen to be as little as possible) provided the product of all a_i + 1 is 2^500500. Since each a_i + 1 must divide 2^500500, a_i = 2^n_i - 1 where the sum of n_i is 500500.
>>
>>55474242
Am i misunderstanding something?
>This should be the smallest
Same argument could be applied for searching for a number with 20 divisors.

As you have showed 2^19 fits but is in no way the smallest.
240 has 20 divisors and 240<2^19 is obviously true.
>>
question is taken from:
https://projecteuler.net/problem=500
i think i have a good way to get a solution, but i'm too lazy to write it up
>>55470782
he asked for the smallest number, consider why 4 has less divisors than 6
>>
>>55470613
I love those threads, but i wish the bird would jsut kill me already
>>
BIRDMIN NO
>>
>>55476676
Stabby stabby
>>
>>55474845
Check the post times faggot.
>>
File: 1466340828478.png (20 KB, 400x398) Image search: [Google]
1466340828478.png
20 KB, 400x398
>>55470737
>>
I can't do it, not even if sober. CAN'T GET THAT ENGINE TURNED OVER.
>>
>>55472627
>Have had
>>
>>55478877
>can't into english
>>
A possibly easy way to do the problema would be to find if the smallest number with 2^500500 divisors is divisibile by 500700, which would mean that the output should be 0
>>
You could also iterate between 0 and 500700 - 1, and maybe the number of full iterations from start to end and the current index could give us informations about the number of divisors... Although in the end you will still have to manage extremely big numbers...
>>
Maybe the fact that the number of divisors is a power of two is a hint that this problem has a particular conformation in binary or another base
>>
>>55480259
i don't think so, consider other ways to express big numbers, there's one that lets you easily calculate how many divisors said number has
>>
Actually I believe the smallest number with n divisors is the smallest number with n-1 divisors multiplied by 2
>>
>>55480348
Wait... no, but I'm onto something
>>
>>55480362
nope
>>
Not sure about this but 1 is the smallest number with 1 divisor, 1*2 = 2 is the smallest number with 2 divisor, 1*2*3 = 6 is the smallest number with 4, 1*2*3*4 = 24 smallest with 8, 1*2*3*4*5 = 120 is the smallest with 16 divisors...
>>
return 1
>>
File: 1460203639407.jpg (45 KB, 500x225) Image search: [Google]
1460203639407.jpg
45 KB, 500x225
>>55470630
>That's a big number
for you
>>
Ok now I'm actually onto something:
if you multiply the first n prime numbers together you get a number that is divisible by 2^n numbers.
Why? 2^n is the cardinality of the power set of n elements, which contains all the possible combinations between the elements of the set.
In this particular case we're talking about all the possible ways to combine a set of n prime numbers by means of multiplication.
Every subset result in a different number since the prime factorization of a number is unique.
The power set has also two more members, which are the empty set, and the set itself, the former is represented by the number 1 which is the divisor of all numbers, the latter by the number itself.
Therefore the number with 2^500500 divisors is the product of the first 500500 primes.
We can agree that 1669 is between the first 500500 prime numbers, therefore the only two prime factors that our BIG number and 500700 have not in common are 2 and 5.
Now:
N / D = Q + R / D
After we remove the common factors we have
(BIG NUMBER) / (2 * 5) = Q + R / D
this look nice, 2 * 5 = 10, so the result of that division is X.Y and since Q is an integer Q.(R/D).
Therefore we only need to know what the last number of that division is! And that's where the computer becomes finally useful.
We can multiplicate the first 500500 prime numbers, except 2, 3, 5 and 1669 and simply keep the result modulo 10 after every product!
Finally you multiply whatever number you got by D = 500700 and you get the answer!

Code incoming!
>>
This should work:
def isprime(n):
for i in range(2, int(sqrt(n)) + 1):
if n % i == 0:
return false
return true

i = 0
n = 2
p = 1
while i <= 500500:
if n == 2 || n == 3 || n == 5 || n == 1669:
++i
++n
else if isprime(n):
p *= n
p %= 10
++i
++n
else:
++n
return (p / 10) * 500700
>>
>>55481322
This actually works:
def isprime(n):
for i in range(2, int(sqrt(n)) + 1):
if n % i == 0:
return false
return true

i = 0
n = 2
p = 1
while i <= 500500:
if n == 2 or n == 3 or n == 5 or n == 1669:
++i
++n
elif isprime(n):
p *= n
p %= 10
++i
++n
else:
++n
print (p / 10) * 500700
>>
>>55481370
for some reason this doesn't work either
>>
I think I don't know python so well anymore:
from math import sqrt

def isprime(x):
for d in range(2, int(sqrt(n)) + 1):
if x % d == 0:
return False
return True

i = 0
n = 2
p = 1
while i <= 500500:
print "" + str(i) + ", " + str(n)
if n == 2 or n == 3 or n == 5 or n == 1669:
i += 1
n += 1
elif isprime(n):
p *= n
p %= 10
i += 1
n += 1
else:
n += 1
print (p / 10) * 500700
>>
>>55481612
the last line should be
print p * 50070
>>
the while should test
i < 500500
>>
>>55481182
>Therefore the number with 2^500500 divisors is the product of the first 500500 primes.
it does indeed have exactly 2^500500 divisors.
but it is not the smallest number, there are a lot smaller numbers. You're on the right track though, you already solved a lot of the problem!
>>
>>55481182
i think(not sure though)
that (a*b) % c = ((a % c) * b) % c
>>
>>55482682
indeed, according to wikipedia:
ab mod n = [(a mod n)(b mod n)] mod n.
Thread replies: 75
Thread images: 9

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.