Re: python script to give a list of prime no.

2020-04-05 Thread Dan Sommers
On Sun, 05 Apr 2020 19:46:00 +0200 Pieter van Oostrum wrote: > Sathvik Babu Veligatla writes: > > > hi, > > I am new to python, and i am trying to output the prime numbers > > beginning from 3 and i cannot get the required output. It stops > > after giving the output "7" and that's it. > >

Re: python script to give a list of prime no.

2020-04-05 Thread Pieter van Oostrum
Sathvik Babu Veligatla writes: > hi, > I am new to python, and i am trying to output the prime numbers beginning > from 3 and i cannot get the required output. > It stops after giving the output "7" and that's it. > > CODE: > a = 3 > l = [] > while True: > for i in range(2,a): > if

Re: python script to give a list of prime no.

2020-04-05 Thread Sathvik Babu Veligatla
On Sunday, April 5, 2020 at 8:03:19 PM UTC+5:30, inhahe wrote: > On Sun, Apr 5, 2020 at 8:26 AM Sathvik Babu Veligatla < > sathvikveliga...@gmail.com> wrote: > > > hi, > > I am new to python, and i am trying to output the prime numbers beginning > > from 3 and i cannot get the required output. >

Re: python script to give a list of prime no.

2020-04-05 Thread Sathvik Babu Veligatla
On Sunday, April 5, 2020 at 8:03:19 PM UTC+5:30, inhahe wrote: > On Sun, Apr 5, 2020 at 8:26 AM Sathvik Babu Veligatla < > sathvikveliga...@gmail.com> wrote: > > > hi, > > I am new to python, and i am trying to output the prime numbers beginning > > from 3 and i cannot get the required output. >

Fwd: python script to give a list of prime no.

2020-04-05 Thread inhahe
On Sun, Apr 5, 2020 at 8:26 AM Sathvik Babu Veligatla < sathvikveliga...@gmail.com> wrote: > hi, > I am new to python, and i am trying to output the prime numbers beginning > from 3 and i cannot get the required output. > It stops after giving the output "7" and that's it. > > CODE: > a = 3 > l =

Re: python script to give a list of prime no.

2020-04-05 Thread Peter J. Holzer
On 2020-04-05 05:22:45 -0700, Sathvik Babu Veligatla wrote: > I am new to python, and i am trying to output the prime numbers > beginning from 3 and i cannot get the required output. It stops after > giving the output "7" and that's it. A technique I learned when I started programming (back in

Re: python script to give a list of prime no.

2020-04-05 Thread Barry Scott
> On 5 Apr 2020, at 14:08, Sathvik Babu Veligatla > wrote: > > On Sunday, April 5, 2020 at 6:09:04 PM UTC+5:30, Chris Angelico wrote: >> On Sun, Apr 5, 2020 at 10:26 PM Sathvik Babu Veligatla >> wrote: >>> >>> hi, >>> I am new to python, and i am trying to output the prime numbers

Re: python script to give a list of prime no.

2020-04-05 Thread Sathvik Babu Veligatla
On Sunday, April 5, 2020 at 6:09:04 PM UTC+5:30, Chris Angelico wrote: > On Sun, Apr 5, 2020 at 10:26 PM Sathvik Babu Veligatla > wrote: > > > > hi, > > I am new to python, and i am trying to output the prime numbers beginning > > from 3 and i cannot get the required output. > > It stops after

Re: python script to give a list of prime no.

2020-04-05 Thread Sathvik Babu Veligatla
On Sunday, April 5, 2020 at 6:04:20 PM UTC+5:30, Orges Leka wrote: > You can try the following: > It is based on trial division and very slow, compared to the state of the > art: > > import math > def is_prime(n): > if int(math.sqrt(n))**2 == n: > return(False) > for i in

Re: python script to give a list of prime no.

2020-04-05 Thread Chris Angelico
On Sun, Apr 5, 2020 at 10:35 PM Orges Leka wrote: > > You can try the following: > It is based on trial division and very slow, compared to the state of the > art: > I think it's more helpful to assist the OP in learning coding, rather than provide a completely different function to do a similar

Re: python script to give a list of prime no.

2020-04-05 Thread Chris Angelico
On Sun, Apr 5, 2020 at 10:26 PM Sathvik Babu Veligatla wrote: > > hi, > I am new to python, and i am trying to output the prime numbers beginning > from 3 and i cannot get the required output. > It stops after giving the output "7" and that's it. > > CODE: > a = 3 > l = [] > while True: >

Re: python script to give a list of prime no.

2020-04-05 Thread Orges Leka
You can try the following: It is based on trial division and very slow, compared to the state of the art: import math def is_prime(n): if int(math.sqrt(n))**2 == n: return(False) for i in range(2,int(math.ceil(math.sqrt(n: if n%i==0: return(False)

python script to give a list of prime no.

2020-04-05 Thread Sathvik Babu Veligatla
hi, I am new to python, and i am trying to output the prime numbers beginning from 3 and i cannot get the required output. It stops after giving the output "7" and that's it. CODE: a = 3 l = [] while True: for i in range(2,a): if a%i == 0: l.append(1) else: