Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7281
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.151 |
| X-Spam-Level | * |
| X-Spam-Evidence | '*H*': 0.71; '*S*': 0.01; 'else:': 0.03; 'googled': 0.09; 'iterate': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'algorithm': 0.16; 'cc:addr:python-list': 0.17; 'cheers,': 0.19; 'header:In- Reply-To:1': 0.21; 'thu,': 0.22; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'creating': 0.24; 'code': 0.24; 'function': 0.25; "i'm": 0.27; 'work.': 0.28; 'wondering': 0.28; 'message- id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.30; 'get.': 0.30; 'print': 0.31; 'this.': 0.31; 'relatively': 0.32; 'does': 0.33; 'post': 0.33; 'break': 0.33; 'chris': 0.34; 'there': 0.35; 'received:google.com': 0.37; 'received:209.85': 0.37; 'bigger': 0.37; 'response': 0.37; 'url:org': 0.38; 'subject:: ': 0.38; 'received:209': 0.39; 'appreciated.': 0.40; 'your': 0.60; 'our': 0.63; 'increase': 0.64; 'prime': 0.73; 'unnecessary': 0.73; 'subject:this': 0.76; 'future,': 0.76; 'subject:..': 0.82; 'bigger,': 0.84; 'num': 0.84; 'sender:addr:chris': 0.84; 'factors': 0.91; 'received:209.85.218.46': 0.91; 'received:mail- yi0-f46.google.com': 0.91; 'to:none': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:cc:content-type :content-transfer-encoding; bh=VwDCJhO1D04Tu6x1SLvbkElBUnJIXpgvhezljNgES6k=; b=VZ+lD096GhCguTVB8GWJm+JOvpcJzA4QfgnaqCj5RpWCjlUgr6C83IAAH8qYHwzA7b r+sCBQs9MbTlMNhTtqr43Lpyxr4eLnn+ZrepxWlW/vUfoW4InIzexHH02iiKb4/Gcv44 zf0/+JzUd1gTPBTKr0IDsp7wdLrQcSlbX/Jas= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:cc:content-type :content-transfer-encoding; b=CJ5Jy2RkWsdi6vVLVXn+VEv0bklzOx65sX4vCPzazCI4IPRlri+2ba8cNJ9AYFo7b1 8JgNcgykfxcvkOyXyoe68R0H44qtCK54atDC+1VguiiyZ9u2/3nfoDKpopSqCG3UFdB7 ZW0cnQ722q91ndsV3dY958JTSIZ3Q2BgfaDQY= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <BANLkTinWq5pjX2+0OVRvm1Xs7ESmYf0qcw@mail.gmail.com> |
| References | <BANLkTinWq5pjX2+0OVRvm1Xs7ESmYf0qcw@mail.gmail.com> |
| Date | Thu, 9 Jun 2011 02:06:06 -0700 |
| X-Google-Sender-Auth | uNlTWZDWjaNtyFzYcfSBWSd9N0w |
| Subject | Re: Any Better logic for this problem.. |
| From | Chris Rebert <clp2@rebertia.com> |
| Cc | python-list@python.org |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.46.1307610371.11593.python-list@python.org> (permalink) |
| Lines | 44 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1307610371 news.xs4all.nl 49041 [::ffff:82.94.164.166]:35053 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:7281 |
Show key headers only | View raw
On Thu, Jun 9, 2011 at 1:31 AM, Ganapathy Subramanium
<sganapathy.subramanium@gmail.com> wrote:
> Hi Guru's,
> I'm working on a solution to find the prime factor of the number
> This part of the code works.. http://www.pastie.org/2041584
For the archives, that code is:
num = 13195
#num = 600851475143L
prime_numbers = [2]
prime_factors = []
for i in range (2,num):
for j in prime_numbers:
if i % j == 0:
break
else:
prime_numbers.append(i)
print 'The Prime Numbers are : ', prime_numbers
for items in prime_numbers:
if num % items == 0:
prime_factors.append(items)
print 'The prime factors are : ' , prime_factors
In the future, please avoid the unnecessary indirection of pastebins
when your code is relatively short. Including the code directly in
your post is also likely to increase the response rate you get.
Cheers,
Chris
> When the number gets bigger, the range cannot iterate through bigger number
> and it does not work.
> When I googled , I came across creating our own range function to solve
> this. I was just wondering if there was a better algorithm to get the prime
> numbers / prime factors of a long number?
>
> Any inputs is highly appreciated.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Any Better logic for this problem.. Chris Rebert <clp2@rebertia.com> - 2011-06-09 02:06 -0700
csiph-web