# Project Euler #179: Consecutive positive divisors

# Project Euler #179: Consecutive positive divisors

+ 2 comments i getting correct answer but for some test case i am getting time out why ?how to avoid that.

+ 0 comments import math def divisors(n): divs = [1] for i in xrange(2,int(math.sqrt(n))+1): if n%i == 0: divs.extend([i,n/i]) divs.extend([n]) return list(set(divs)) n = input() a = [] for i in range(n): count = 0 a.append(input()) adict = {} for j in range(a[i]): k = j+1 adict[k] = divisors(k) for m in adict: if m!=len(adict): if len(adict[m])==len(adict[m+1]): count = count+1 print count

I am getting time out error for this, I think I am runnig out of space, can anyone suggest for an alternative in python

+ 2 comments First off, I do not want to look at any code what-so-ever. I'm asking for a nudge in the right direction.

In the test cases shown, where do they get 15?

input: 100

output: 15

I guess I am not understanding the problem.... k is the input right? So I need to iterate through every value of n such that 1 < n < k where k = 100?factors for 100: 100,50,25,20,10,5,4,2,1

Is it asking which of the consecutive positive divisors has the same amount of factors?Or, is it asking for the first pair of numbers up to 100,

where n is:

nSub1, nSub2, nSub3, ... , nsub97, nsub98, nsub99

2, 3, 4, .... , 97, 98, 99wanting the first value of n that has the same number of divisors as n+1?

If this is the case, 15 does not make sense to me. Please help!

+ 1 comment i am getting timeout error always when i try to run the program on c#.. pls increase the timeout period. same thing was happened on previous problem also

+ 1 comment Using custom test cases my solution time never hits a second however the tester is saying it times out at 4 seconds. I don't see how this could be.

Sort 60 Discussions, By:

Please Login in order to post a comment