Coding challenge, I want to see how dumb you fuckers are

Coding challenge, I want to see how dumb you fuckers are.

Heeeere we go:

A magic number is defined as a number which has more factors than any number below it.

For example, if we look at the number of factors for 1 through 6, we get the following, with n being the number checked and f being the number of factors it has:
n:1, 2, 3, 4, 5, 6
f:1, 2, 2, 3, 2, 4

In this sequence, we can tell that 1 is a magic number, then 2, then 6. 3 is not a magic number because it does not have a *larger* number of factors than any number smaller than it.

Write me a program which will generate magic numbers from 1 to n, where n is specified by user input.

Bonus points to those who find efficiency shortcuts.

I'll try

>Please do my programming homework for me.

What kind of fucktard gives a challenge and can't even get his own example right? 4 is also a magic number you insufferable degenerate.

Yeah, pardon me..

Fuck off. I've already done it, I just want to see how other attempts compare to it.

nice pic from tumblr, cunt

Joke's on you, faggot. I saved that from Sup Forums. What does that mean about you?

lucky trips and I fucked up the quote..

Should be

bump, solution incomming

def factors(n):
f = 0
for i in range(1,n+1):
if n%i ==0 :
f = f+1
return f
def magic(n):
l = []
for i in range(1,n+1):
l.append(factors(i))
return l # NOT DONE

this is what I have so far, trying to figure it out

OP is 14 year old and needs help with his homework because he's fucking retarded

bamp

See:

I see where you're going with that. factors(n) looks all fine!

bemp

Don't you mean "all" numbers below it?

If
Then
Cout
Cin
My nuts
Cin some more
Cout my semen faggot

AIDS happened because a nigger fucked a monkey

>, I want to see how dumb you fuckers are

no, you want us to do your homework for you

and that's how dumb YOU are

Do
Your
Own
Fucking
Homework
Pleb.

def factors(n):
f = 0
for i in range(1,n+1):
if n%i ==0 :
f = f+1
return f

def compare(list1,value):
#print("L",list1)
for i in list1:
if i>=value:
return False
return True

def magic(n):
l = [] #list of factors
for i in range(1,n+1):
l.append(factors(i))
print(l)
r = [] #list of magic numbers
for i in range(len(l)):
if i == 0:
r.append(1)
elif i == 1:
r.append(2)
elif i == 2:
pass
else:
if compare(l[:i-1],l[i]):
r.append(i+1)
return r

fuck I hope this is right
I know, it's inefficient

Fuck it. OP here.

pastebin com/bnaMLhn5

That's my solution. Don't mind the messy start to the output.

I got bored waiting for you lot so I added another printout which tells you how long it took to get to that number.

Jesus Christ user, where did you learn to code??

Actually yeah, I see what it does - prints an array of the number of factors of numbers, such that the index of a value is the number being checked, plus one.

Doesn't actually get me magic numbers though.

mainly self-taught

dammit

Don't worry, with that final array you can work out the magic numbers for it. That does mean the program will only output once it's done all of its processing though - meaning we will be waiting forever if you want it to generate to infinity.

42

So, a couple of efficiency shortcuts I recognised:
- If a number above two is prime, we can skip checking for if it's magic. This is what caused the messy output.
- To find the 'next' magic number, we only have to look between the current one and onwards. There's no point starting from zero again because the magic number only has to beat the last magic number for factors.

Lucky trips again. Damn..

Looking at it, just realised you can skip odd numbers too.

integer n = input(n) //add invalid response catching here
inter num = integer.randombetween(1, n)
do
do
integer nFactors = 0
integer mFactors1 = 0

for x = 1 to num
if (num mod x) == 0 then
nFactors++
endif
next x
for x = 1 to (num - 1)
if ((num - 1) mod x) == 0 then
mFactors++
endif
next x

if nfactors > mfactors then
magicAquired = true
print(num)
endif

while magicAquired != true
cont = input(continue yes/no)
while cont != "no"

oh fuck, I thought it was meant to be that it generates random numbers. Oh well, it is good enough.

Fortran

print *, 'enter max integer'
read *, n
allocate(a(n))

do i = 1,n
k = 0
do j=1,i
x = mod(i,j)
if (x .eq. 0) then
k = k + 1
end if
end do
a(i) = k
end do

do i = 1,n
x = 0
do j=1,(i-1)
if (a(i) .gt. a(j) then
x = x + 1
end if
end do
if (x .eq. (i-1)) then
print *, i
end if
end do

One of you faggot write it in brainfuck

...

>I want to see how dumb you fuckers are.

I love how everyone can see through this manipulation tactic that is used by women kek