Author |
Message |
Forum: Computers, Math, Science, and Technology Topic: Method for generating prime numbers |
NeantHumain |
Posted: 16 Feb 2012, 10:16 am
|
|
Replies: 112 Views: 21,824
|
Ha, anyway if we're talking optimizations, one thing is to substitute an equivalent iterative algorithm in place of the recursive one. The recursive algorithm runs the risk of a stack overflow for larger numbers, not to mention the overhead of calling a function, pushing its arguments onto the stac... |
|
|
Forum: Computers, Math, Science, and Technology Topic: Method for generating prime numbers |
NeantHumain |
Posted: 15 Feb 2012, 11:20 pm
|
|
Replies: 112 Views: 21,824
|
I found an O(n) time algorithm to generate the first n prime numbers. I've already sent it to the NSA. C++ code: #include<iostream> using namespace std; int main() { int n; cin >> n; for(int i = 0; i < n; i++) { print_prime(i); } return 0; } This is assum... |
|
|
Forum: Computers, Math, Science, and Technology Topic: Method for generating prime numbers |
NeantHumain |
Posted: 15 Feb 2012, 8:01 pm
|
|
Replies: 112 Views: 21,824
|
Did you program in C before it was cool? Ha, anyway if we're talking optimizations, one thing is to substitute an equivalent iterative algorithm in place of the recursive one. The recursive algorithm runs the risk of a stack overflow for larger numbers, not to mention the overhead of calling a func... |
|
|
Forum: Bipolar, Tourettes, Schizophrenia, and other Psychological Conditions Topic: Euphoria |
NeantHumain |
Posted: 15 Feb 2012, 7:29 pm
|
|
Replies: 6 Views: 1,201
|
Probably cyclothymia or something else on the bipolar spectrum. |
|
|
Forum: Computers, Math, Science, and Technology Topic: Method for generating prime numbers |
NeantHumain |
Posted: 14 Feb 2012, 11:03 pm
|
|
Replies: 112 Views: 21,824
|
I'm actually doing the same, for consistency. ArrayList scales poorly compared to array, because it needs to jump to random places in the RAM, so for all the methods I allocate for worst case. The sieve obviously needs it, but I find that the more naive methods benefit from it as well. The dynamic ... |
|
|
Forum: Computers, Math, Science, and Technology Topic: Method for generating prime numbers |
NeantHumain |
Posted: 14 Feb 2012, 12:30 am
|
|
Replies: 112 Views: 21,824
|
You can optimize it heavily by only searching up to the square root of the target, and by incrementing twice in the prime checker function itself, as it cuts the worst case down to 1/2 (worst case being a prime). Incrementing twice for checked values had little to no improvement on my java tests. :... |
|
|
Forum: Politics, Philosophy, and Religion Topic: What is your Opinion of Pornography in Public Libraries? |
NeantHumain |
Posted: 13 Feb 2012, 10:25 pm
|
|
Replies: 119 Views: 10,794
|
Is there really a right to wank? |
|
|
Forum: Computers, Math, Science, and Technology Topic: Method for generating prime numbers |
NeantHumain |
Posted: 13 Feb 2012, 9:10 pm
|
|
Replies: 112 Views: 21,824
|
Since I'm not a mathematician, I'll use a naïve algorithm, illustrated in C: ... That actually tests whether the arguments are prime or not. This one generates all the prime numbers from 1 to the first argument (inclusive). Again, it's a naïve, "brute-force" algorithm: #include <stdlib.h> #include ... |
|
|
Forum: Computers, Math, Science, and Technology Topic: Method for generating prime numbers |
NeantHumain |
Posted: 13 Feb 2012, 8:55 pm
|
|
Replies: 112 Views: 21,824
|
Since I'm not a mathematician, I'll use a naïve algorithm, illustrated in C: #include <stdlib.h> #include <stdio.h> typedef enum {FALSE, TRUE} BOOL; BOOL test_factors(unsigned long factor, unsigned long integer) { BOOL result = TRUE; if (factor < integer) { if ... |
|
|
Forum: Politics, Philosophy, and Religion Topic: What Is Your Main Grievance with Obama's Presidency? |
NeantHumain |
Posted: 11 Feb 2012, 6:33 pm
|
|
Replies: 118 Views: 7,958
|
Obviously, the polling options were written by a neo-con, because there are genuine reasons for liberals or people who voted for Obama to not like him. For example, he didn't push hard enough to pass a payer, healthcare system, he didn't get us out of Iraq war in the time frame he campaigned on, he... |
|
|
Forum: Politics, Philosophy, and Religion Topic: What IS liberalism? What IS conservatism? |
NeantHumain |
Posted: 10 Feb 2012, 12:57 am
|
|
Replies: 44 Views: 3,660
|
This also shows how pointless the "big versus small government" discussion is. Conservatives promote a big government when it comes to restrictive social policies and military spending, but oppose it in regard to market regulation, welfare and public sector spending. Liberals advocate the exact opp... |
|
|
Forum: Politics, Philosophy, and Religion Topic: What Is Your Main Grievance with Obama's Presidency? |
NeantHumain |
Posted: 08 Feb 2012, 10:28 pm
|
|
Replies: 118 Views: 7,958
|
This question is mainly aimed at conservatives although moderates and liberals have concerns of their own. The poll options tend to reflect common conservative criticisms over the last three years. ⋅ President Barack Obama lacks legitimacy for the office of President. In a narrow sense, t... |
|
|
Forum: Politics, Philosophy, and Religion Topic: American Constitution Losing Appeal |
NeantHumain |
Posted: 08 Feb 2012, 9:30 pm
|
|
Replies: 95 Views: 6,604
|
We must remember that our current Constitution was already a "redo" from the original Articles of Confederation, and for the time, our Constitution was the state of the art in political science, incorporating ideas from influential Enlightenment thinkers like Montesquieu (separation of powers), Rous... |
|
|
Forum: Bipolar, Tourettes, Schizophrenia, and other Psychological Conditions Topic: Perfectionism and OCD |
NeantHumain |
Posted: 08 Feb 2012, 7:56 pm
|
|
Replies: 16 Views: 4,626
|
The psychiatrist put him on this because he has a diagnosis of autism and he has aggression issues. This is the drug du jour for these kids. I talk to his psychiatrist about things he is experiencing and I feel he isn't listening and I'm having my reservations. With something like this I need to tr... |
|
|
Forum: Computers, Math, Science, and Technology Topic: I can't get hibernate back. |
NeantHumain |
Posted: 07 Feb 2012, 11:24 pm
|
|
Replies: 6 Views: 941
|
|
|
Forum: Bipolar, Tourettes, Schizophrenia, and other Psychological Conditions Topic: Perfectionism and OCD |
NeantHumain |
Posted: 07 Feb 2012, 8:22 pm
|
|
Replies: 16 Views: 4,626
|
Greetings! I have a couple of questions: Is perfectionism a manifestation of OCD? What drugs do you give to a person for OCD? Is Risperidone one of them? and/or can Risperidone cause OCD to become worse? I want to better manage my son's medication since I don't like his psychiatrist and I'm in the ... |
|
|
Sort by: |