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.
Noah Campbell
I'll try
Ryan Parker
>Please do my programming homework for me.
Jaxson Jackson
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.
Matthew Myers
Yeah, pardon me..
Joshua Davis
Fuck off. I've already done it, I just want to see how other attempts compare to it.
Blake Foster
nice pic from tumblr, cunt
Adam Wright
Joke's on you, faggot. I saved that from Sup Forums. What does that mean about you?
Adam Wright
lucky trips and I fucked up the quote..
Should be
Brandon Cooper
bump, solution incomming
Connor Young
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
Benjamin Butler
OP is 14 year old and needs help with his homework because he's fucking retarded
Aiden Sanchez
bamp
Colton Allen
See:
Thomas Gomez
I see where you're going with that. factors(n) looks all fine!
Charles Barnes
bemp
Brandon Rivera
Don't you mean "all" numbers below it?
Elijah Green
If Then Cout Cin My nuts Cin some more Cout my semen faggot
Kayden Lee
AIDS happened because a nigger fucked a monkey
Colton Murphy
>, 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
Brody Ward
Do Your Own Fucking Homework Pleb.
Logan Davis
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
Caleb Mitchell
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.
Camden Lopez
Jesus Christ user, where did you learn to code??
Nathan Garcia
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.
Robert Bell
mainly self-taught
Liam Ross
dammit
Carter Baker
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.
Xavier Williams
42
Ryan Fisher
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.
Matthew Taylor
Lucky trips again. Damn..
Luis Davis
Looking at it, just realised you can skip odd numbers too.
Jaxon Cox
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"
Nathaniel Adams
oh fuck, I thought it was meant to be that it generates random numbers. Oh well, it is good enough.
Ryder Scott
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
Elijah Lee
One of you faggot write it in brainfuck
Matthew Richardson
...
Bentley Perez
>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