[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

lets see how fast you can do it. java only.

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 15
Thread images: 1

File: Screenshot_1.png (26KB, 1291x393px) Image search: [Google]
Screenshot_1.png
26KB, 1291x393px
lets see how fast you can do it.

java only.
>>
>java only
Fuck off with your homework
>>
Use DYODH algorithm.
>>
please.
>>
>>59533408
No.

If we help you with the easy shit you'll just become another weak programmer whose deadweight forces us to work harder.

Think hard. Read your textbook. Learn to carry your own weight.
>>
>another shitskin appealing to collectivism
*yawn*
Just drop out
>>
Let me teach you how to properly cheat and do shit in the class. I don't care how badly you do; you're failing at algorithms and a CS degree is an algorithms degree. Here's how I'd solve this problem if I wanted to get nowhere.

Step 1, look up what other people have done on stackoverflow. (i.e. look up code for a sieve of eratosthenes in java)

Step 2, copy and paste whatever has the most flexability

Step 3, you're basically done, just add like 3 more variables and set them inside the already-made if-statements.

Step 4, fuck off
>>
>>59533352
there's an active fucking thread about this RIGHT NOW, you could have spent 2 seconds looking at the solutions and rewriting it in java.

But you can't even do that.
DROP OUT RIGHT NOW
>>
>>59533352
Why the fuck would you use recursion to implement Sieve of Eratosthenes?
>>
>>59533352

#include <bitset> // compact STL for Sieve, better than vector<bool>!
ll _sieve_size; // ll is defined as: typedef long long ll;
bitset<10000010> bs; // 10^7 should be enough for most cases
vi primes; // compact list of primes in form of vector<int>
void sieve(ll upperbound) { // create list of primes in [0..upperbound]
_sieve_size = upperbound + 1; // add 1 to include upperbound
bs.set(); // set all bits to 1
bs[0] = bs[1] = 0; // except index 0 and 1
for (ll i = 2; i <= _sieve_size; i++) if (bs[i]) {
// cross out multiples of i starting from i * i!
for (ll j = i * i; j <= _sieve_size; j += i) bs[j] = 0;
primes.push_back((int)i); // add this prime to the list of primes
} } // call this method in main method
bool isPrime(ll N) { // a good enough deterministic prime tester
if (N <= _sieve_size) return bs[N]; // O(1) for small primes
for (int i = 0; i < (int)primes.size(); i++)
if (N % primes[i] == 0) return false;
return true; // it takes longer time if N is a large prime!
} // note: only work for N <= (last prime in vi "primes")^2
// inside int main()
sieve(10000000); // can go up to 10^7 (need few seconds)
printf("%d\n", isPrime(2147483647)); // 10-digits prime
printf("%d\n", isPrime(136117223861LL)); // not a prime, 104729*1299709


it's from competitive programming 3
>>
>>59533352
Rajeet, my friend, you should have finished your assignment earlier in the week.
>>
>>59533962
This is the correct answer
>>
>>59533352
>lets see how fast you can do it
>/g/, do my homework
>>
This isn't hard OP. Do your homework, it's good for you. Answer these questions :

What is a prime number?
How would you test in your head if a number is prime?
>>
A tip: use / and \ is 7/2 the same as 7\2?
Thread posts: 15
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.