Group: General Forum Members Last Login: Friday, March 19, 2010 1:30 PM Points: 110,Visits: 37

Fun stuff.

I tried to do something similar in VB several years ago...the trick was that I was trying to solve for primes bigger than any of the data types. I ran out of time before I solved it...but it sure was a fun exercise!

Group: General Forum Members Last Login: Sunday, December 14, 2014 11:20 PM Points: 1,Visits: 136

Kathi

In the book you mentioned, Chris has Aspbergers Syndrome (rather than being autistic). There are many similarities, but people with Aspbergers for the most part can lead relatively 'normal' lives. There are varying degrees of both of course, and it's sometimes hard to make a clear distinction where one ends and the other begins.

Group: General Forum Members Last Login: Today @ 12:57 AM Points: 41,247,Visits: 38,556

Hi Ryan,

What did you come up with for the largest prime number found and how many prime numbers? I wanna make sure I'm doing it right...

--Jeff Moden"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

Group: General Forum Members Last Login: Friday, June 17, 2011 6:28 AM Points: 422,Visits: 33

My suggestion, on our SQL Server 2000 installation it finds all primes less than 5000000 in 54 seconds. But of course it depends on the hardware...

set nocount on go

select top 5000000 identity(int, 1, 1) as Number into #Numbers from syscomments c1 cross join syscomments c2 go

alter table #Numbers add constraint PK_Numbers primary key clustered (Number) go

create table #Primes(prime int primary key) go

declare @time datetime select @time = getdate()

declare @i int set @i = 1 while @i*@i < 5000000 begin insert into #Primes select n.Number from #Numbers n where n.Number < (@i+1)*(@i+1) and n.Number > @i*@i and not exists ( select * from #Primes p where p.prime < @i + 1 and n.Number % p.prime = 0

You cannot post new topics. You cannot post topic replies. You cannot post new polls. You cannot post replies to polls. You cannot edit your own topics. You cannot delete your own topics. You cannot edit other topics. You cannot delete other topics. You cannot edit your own posts. You cannot edit other posts. You cannot delete your own posts. You cannot delete other posts. You cannot post events. You cannot edit your own events. You cannot edit other events.

You cannot delete your own events. You cannot delete other events. You cannot send private messages. You cannot send emails. You may read topics. You cannot rate topics. You cannot vote within polls. You cannot upload attachments. You may download attachments. You cannot post HTML code. You cannot edit HTML code. You cannot post IFCode. You cannot post JavaScript. You cannot post EmotIcons. You cannot post or upload images.