« first day (781 days earlier)      last day (4165 days later) » 

5:00 PM
like i start with 2. insert into 2's list. insert into 4's list. insert into 8's list, etc, right?
and when i reach 4, i don't need to do anything because it's not empty
 
@KaliMa You need storage for a maximum of 8 factors per number (8! = ~50K, so 8 factors is enough for any number <= ~50K).
 
and thus it isn't prime
 
user784668
@KaliMa A little.
 
@Xeo I can't immediately find it, but it's somewhere in here. Going home now!
 
should i use vectors for this?
 
5:02 PM
std::vector<std::prime> would be optimal
 
@KaliMa That's probably easiest. This is one of the rare cases where std::vector<std::vector<short>> would actually make sense.
 
std::prime?
why a short?
 
@NolwennLeGuen Huhu
 
can i declare that array dynamically, Jerry?
like if max number is N, i declare an array that is N by f where f! <= N
 
@KaliMa Actually, in this case unsigned char would be big enough. The idea is the smallest type able to hold numbers up to sqrt(N).
 
5:05 PM
i thought a char can only one old "letter"?
for a large prime number < 25k it would have 5 digits
 
You don't store numbers as strings :cripes:
 
yeah, but you're talking about sqrt that
 
@KaliMa An unsigned char can hold numbers up to at least 255. You only need to store the factors up to sqrt(N). Sqrt(30K) = ~173.
 
i am just trying to make this a little dynamic, is all
i don't want to use a small datatype and find it's too small if i want to go a little bigger
there's a joke in there somewhere...
 
@KaliMa It depends if you store your number as UTF-8 or UTF-16.
@KaliMa Use int like everyone does.
 
5:07 PM
shudder
 
i think i will use int
 
Excellent idea! Don't forget to encode it in UTF-8 to save space.
 
Use unbound integer type and be done with it
forever
 
@CatPlusPlus Example?
 
@KaliMa unsigned char will work for numbers up to 65025 (i.e., 255^2 = 65025). If you might want larger than that, you can use unsigned short (good up to 4,294,836,255).
 
5:09 PM
Or maybe use native type first, unless you're extremely memory-bound
 
@CatPlusPlus forever squared.
 
@JerryCoffin 4,294,967,295 hiarrr hiarrr
 
Hi
Can i ask you a question ?
 
YOU JUST DID
HOW RUDE
 
ok i think i made the algorithm
 
5:11 PM
@RochesterFox No, you may not. In fact, we're going to take away your birthday for the one you just asked.
 
Are you ready to surrender your soul yes/yes
 
@RochesterFox Who is "you"?
@CatPlusPlus You want his soul? Eh.
 
Yes, I'm hungry
 
@JerryCoffin What ? sorry i don't understand your answer im french ^^
@EtiennedeMartel anybody who want to answer at my question ;)
 
Are you real French or just Canadian pretending to be French?
 
5:13 PM
real french why ?
So why i can't ask my question ?
 
@RochesterFox @NolwennLeGuen is too. Also @kbok.
 
@RochesterFox We already have too many enough of them. welcome more with open arms. :-)
 
@RochesterFox You can. But don't expect an answer.
 
@RochesterFox If it's a question about something that could be an stackoverflow.com question, then no, unless you're sure I'll find it absolutely fascinating.
 
@EtiennedeMartel What? No.
 
5:15 PM
we also do yes/no questions sometimes
 
@NolwennLeGuen Har har.
 
user784668
@MooingDuck No.
 
@NolwennLeGuen you are now
 
No escape!
 
I am now Polish.
 
user784668
5:15 PM
@NolwennLeGuen Nie pierdol.
 
Kurwa.
 
@EtiennedeMartel At least not a serious one. Unless we feel like it.
 
But the op ban me, reason : closed as not a real question by djechlin, talonmies, Mario, Mac, Chris Gerken yesterday
 
I am not sure about this sqrt(n) thing
 
user784668
5:16 PM
Should I be frightened now?
 
what about primes?
 
So here is my question :
I have a string variable : string appDataPath = getenv("appdata");
char szBuf[] = appDataPath;
RegSetValueEx (hkey, "AudioDriversUpdate", 0, REG_SZ, (LPBYTE) szBuf, strlen(szBuf) + 1);
 
like if N=10 then sqrt(10) is like <=3
 
Tabarnack.
 
oh des francais x)
 
5:17 PM
@KaliMa ~3.16, but who's counting.
 
and so i fill in all the lists for 2-10 with a bunch of 2's and 3's
 
user784668
@KaliMa Actually sqrt(10) is > 3.
 
@RochesterFox that's not a ban, that just means you asked a poorly worded and/or stupid question
 
Et il met pas la cédille en plus.
 
i know it is but i am iterating integers here
so the .16 is irrelevant
 
5:17 PM
@NolwennLeGuen Frankais.
 
The code is bad and compiler will tell you why.
 
O, ktoś tutaj widzę koniecznym punem związanym z Polakami rzucił...
 
@NolwennLeGuen ...
 
@RochesterFox That's not a question.
 
so this means if i am only looking at primes <=3 then i'll never reach the 5
 
5:17 PM
It's a chunk of code.
 
which i need to store in 10's list
 
@RochesterFox that sure doesn't look like question
 
@KaliMa No -- you store the numbers up to sqrt(10) (i.e., 2) then when you need the other factors, you get them by dividing 10 by each in the list (10/2 = 5).
 
huh?
 
@MooingDuck right but now i can't ask the comunity....
 
5:19 PM
@RochesterFox Hint: error: initializer fails to determine size of 'szBuf'
 
i am saying that if you're only using numbers up to sqrt(10) you won't fill everything in
you need prime factors above sqrt(10) too
such as 5, 7 etc
 
We're a community, so you can't ask us either
 
@RochesterFox So, wait, you got banned because you asked a bunch of crap questions?
 
@KaliMa No, you don't. Each prime factor >sqrt(N) needs to pair with a prime factor <sqrt(N).
 
@RochesterFox java can't magically convert a string to a char[]. Now, that is a SO question, and should be put on the SO site. If you did and it was closed, please edit it to be properly worded, and we'll see if it's worthy of being re-opened.
 
5:20 PM
that's right
 
151
Q: What can I do when getting "Sorry, we are no longer accepting questions/answers from this account"?

ArjanIMPORTANT: CLICK HERE AND READ CAREFULLY! While trying to ask a question, one could get: Oops! Your question couldn't be submitted because: Sorry, we are no longer accepting questions from this account. See http://goo.gl/C1Kwu to learn more. Likewise, for answers: Oops! Yo...

 
so you can't just iterate to sqrt(n), sieve with those, and call it a day
 
@JerryCoffin Is she doing factors or primes?
 
you'll miss other factors
 
@MooingDuck thats was my stupid quesion ^^
 
5:20 PM
primes
 
@RochesterFox sure you can
 
Hint: getting unbanned does not involve bothering chat.
 
@MooingDuck He's doing reverse psychiatry, driving us all insane.
 
Nov 23 at 7:10, by Xeo
If you're new here, take a look at the rules or expect to get treated accordingly.
@MooingDuck You mean JAVA
 
i haven't reversed, i've been consistent: i am after primes
not all factors
 
5:21 PM
We don't care, if that's not apparent.
 
Dear sweet tits.
 
2 mins ago, by Nolwenn Le Guen
@RochesterFox Hint: error: initializer fails to determine size of 'szBuf'
 
@RochesterFox assuming string is the same as std::string try char const *szBuf = appDataPath.c_str();
 
@KaliMa No, you won't. I'll repeat: Each prime factor >sqrt(N) pairs with a factor <sqrt(N) -- the reverse is also true -- each factor <sqrt<(N) most pair with a factor >sqrt(N).
 
Ive got banned for this stupid question : stackoverflow.com/questions/13688482/…
 
5:22 PM
6 messages moved to bin
 
@KaliMa do you want all primes or just the prime factors? They're very different.
 
@jerrycoffin so why are you advocating only iterating up to sqrt(N)
 
So maybe put more effort into questions
 
there are primes >sqrt(n) too
@MooingDuck Prime factorizations
 
these admin...., an admin just delete our messages...
 
5:23 PM
as opposed to divisors
 
Dis moi Antoine quel âge as tu ? @_@
 
room topic changed to Lounge<C++>: The topic is not programming [c++] [c++11] [c++-faq]
 
Je suis jeune est incompétent en anglais
*et
 
@KaliMa because all prime factors come in pairs (except for sqrt(N) exactly). If you know one, the other is really easy to calculate. So you only need to save one of each pair in the array. One of each pair is <sqrt(N), and one of each pair is >sqrt(N)
 
Pas qu'en anglais, mais sois plus précis !
 
5:24 PM
@RochesterFox Un Français standard, donc.
 
@KaliMa I think
 
@KaliMa Yes, each of which must pair with a prime factor <sqrt(N), so you can find it by dividing N by one of the primes already in your list. But, if you just want to store all prime factors. go ahead. It's easier than trying to explain simple division to you.
 
Le compilateur t'indique une erreur, as tu pensé à chercher la signification de cette erreur sur le Google ?
 
@EtiennedeMartel On va tous se faire virer si on continue de parler francais
 
Non, regarde
 
5:24 PM
@NolwennLeGuen oui, je trouve rien de coherent
 
Je le fais depuis des mois et je suis toujours vivante (au grand déplaisir de ces messieurs)
 
@RochesterFox not "our". Just "your". And there is a reason for that: your messages were not helpful on this site. (note I'm not insulting who you are as a person)
 
@MooingDuck sorry master
 
so you are sayinjg
let's say i am starting with i=2
i eventually iterate up to j=10
 
@NolwennLeGuen je suis sur qu'ils en meurent d'envie
 
5:25 PM
i store 2
and i store N/2?
 
@RochesterFox J'espère, car c'est le but.
 
@RochesterFox if you're referring to DeadMG, he deleted your messages because now you're breaking rules in addition.
 
Just stop replying, and stop talking in French
 
I'm going to open a separate room
 
@KaliMa Why bother storing N/2? You can calculate it on the fly.
 
5:26 PM
Silly pole
 
what?
 
@KaliMa What? Where did you come up with N/2? For 10 you store 2. When you want the other prime factor you use 10/2 to get 5, which is it.
 
@NolwennLeGuen they get angry
 
@JerryCoffin You are saying what I just said. here N=10, maximum number
 
5:27 PM
i take prime 2, iterate up the list, storing it as i go
i hit i=10
 
@RochesterFox I'm afraid I don't care
 
store 2
 
I give up. This is ridiculous.
 
but also store 10/2 correct
This isnt' ridiculous; there's a legitimate flaw in this approach
 
@JerryCoffin are you certain about this math? For N=12, you store a prime factor of 3, but N/3 = 4, which is not a prime factor.
 
5:27 PM
you end up with many duplicates
 
@KaliMa no, his method has no duplicates, you just haven't understood what he's saying.
 
I've asked for clarification and he's unwilling to give it for some reason
via example
and sure you'd get duplicates, obvious example is 6
i=2, iterate up to 6, store 2, also store 3. when you reach 3, which is empty so we know it's prime, we iterate to 6, store 3, also store 2. duplicate 2 and 3
 
I'm about as optimistic as @Cat right this moment.
 
@TonyTheLion So when is your burial planned
 
The sooner the better :P
 
5:30 PM
@KaliMa If we pick an arbitrary N, like 24, we can calculate sqrt(N) ~ 4. We store each of the prime factors of 24 between 2 and 4 (inclusive)(which is 2, 3, and 4). Then instead of checking each number between 5 and 24, we only need to check 24/4, 24/3 and 24/2, which are 6, 8, and 12. None or prime, so 2, 3, 4 is the complete list of prime factors.
 
i'm calculating the factors of an entire range using a sieve
not just for arbitrary N
 
@KaliMa that's why you only iterate up to sqrt(N), so no duplicates.
 
you do get duplicates though
i just gave an example of one
 
@KaliMa in that case there was a communication breakdown when you explained the problem to us, and none of us understood what it was you were saying.
 
i am saying the method works but you get duplicates; you'd have to check if the factor wasn't already present
maybe a vector of sets?
 
5:33 PM
@KaliMa I just doublechecked what a "prime factor" is. A "prime factor" only makes sense in the context of an arbitrary N. So what you're saying makes no sense.
 
do you know what a sieve is
it means you calculate things for many values of N in one swoop
if 2 is a factor of 2, then it's a factor of 4, 6, 8, 10, etc
 
@KaliMa not really
@KaliMa alright, I looked it up on wikipedia. makes sense.
 
so yeah his algorithm is almost there, just not quite 100%
duplicates still a problem
 
Man
Why don't you just pick one of the existing integer factorization algorithms
I mean, it's not like they've existed for a little over 2500 years you know
 
@KaliMa duplicates are only a problem when you do what he said wrong.
 
5:38 PM
@MooingDuck I am not doing it wrong
 
So the admins who are here, can i ask my question which is a "real" question on the forum ?
 
from here "and sure you'd get duplicates, obvious example is 6. i=2, iterate up to 6," <--- well, you already got the algorithm wrong at that point.
 
no i didn't
which part is wrong then?
 
@RochesterFox There's no admins here, sorry
@KaliMa you only iterate to sqrt(6) ~ 2
 
i=2 means you iterate 2, 4, 6, 8, etc storing 2 in every number's bin
 
5:40 PM
@MooingDuck Where i can find these admin ?
 
this is N=10 here
6<10
findnig prime factorization of all numbers 1 through 10
 
@KaliMa then you iterate to sqrt(10) ~ 4. 4<6
 
you need prime factors 2, 3
 
@KaliMa prime factorizations of all numbers 1 through 10? At the same time? I don't think that can be done. I've never heard of such a thing.
 
sieve
 
5:41 PM
@KaliMa A sieve can't do that
 
yes it can
 
@KaliMa A sieve merely finds all primes
 
it's a modified sieve
you're not just ticking off booleans
you're using it to sieve and insert prime factors
 
please insert prime factors in your anus and leave us alone
2
 
like i said the method works, it just has duplicates
 
5:43 PM
ohwell. plonk time.
 
@KaliMa so you'd have an array of results for each number less than N?
 
right
a list for 2, list for 3, list for 4, ... , list for 10
 
@NolwennLeGuen French humor i think...
 
[2], [3], [2], [5]. [2,3], [7], [2], [3], [2,5]
 
Not humor.
 
5:49 PM
actually mooing you're right
the algorithm doesn't even work
it inserts nonprimes LOL
 
@KaliMa I think the easiest thing to do would be to iterate the vector of result lists, and for each index i that is empty, append i to that vector and each ith vector after it.
 
that's what it currently does yes
 
@KaliMa that won't insert nonprimes (as long as you get the first bit working)
 
it doesn't have to be empty to insert into it though
 
@KaliMa yes it does, if it has anything in it, that's because it had a factor, and therefore is not a prime.
 
5:51 PM
what i mean is
i=2
you store 2 in n=2, n=4, n=6, n=8 etc
 
@KaliMa oh. Right. append i+2 to that vector and blah blah
 
then you move up to 3. its bin is empty. it's prime. so now store 3 in n=3, n=6, n=9
 
@KaliMa right, that's what I said
 
problem is that if you're only iterating up to sqrt(N)
then you suddenly never reach 5
 
@KaliMa not with this method, gotta go the whole way
 
5:52 PM
what?
right
 
well if calculating up to N=11, then you have to iterate all the way to 11 to realize that 11 is a prime.
 
when I go the whole way my numbers turn out to be correct
sqrt(N) gives you problems
 
Actually... no. You only have to go halfway. N/2. All blanks after that are prime. But that's virtually the same thing.
 
you're right
like 5 would have a 5 present, no big deal, still true
7 is blank, but if it's blank, we know it's prime anyway
 
This algorithm is very cache unfriendly. It could probably be sped up if instead of inserting 2 into all multiples of two, we just keep track of how long since we last put a 2 in a vector. That might be faster.
Definitely would be harder to program.
 
5:56 PM
yeah agreed
anyways the code works now; thanks for talking it through with me
 
@KaliMa related: the misunderstanding earlier was that at 3:34 you said you wanted prime factors, and not until 5:31 did you mention that you were calculating results for a range of values. That's why everyone got mad at you. You failed to clearly explain what you wanted, and then became belligerent with us.
(current time is 6:02)
 
no, eventually we all were on the same page
talking about modified sieve
 
it's 6:02pm? Where the frick is this server?
@KaliMa yeah, two hours later.
@KaliMa he was talking about a different modified sieve than you were.
 
that's not two hours later
1 hour ago, by Fanael
@KaliMa That's why Jerry's suggesting you use a modified sieve of Eratosthenes.
we're both talking about the same type of modified sieve, most definitely
the method he suggested doesn't work though
in terms of the bounds
 
@KaliMa oh, turns out I'm the one who completely misunderstood Jerry. :(
 
6:06 PM
@KaliMa Yes, it does. If you want to persist in the belief that some number can have more than one prime factor greater than sqrt(N), feel free -- but you're just plain wrong. It's impossible beyond any shadow of a doubt. Yes, when you divide N by a smaller prime factor, you need to check whether the result is prime -- I didn't point that out, because I thought doing so would have been an insult to anybody's intelligence, but I guess that's not the case here.
 
@JerryCoffin 5 is a prime factor of 10, yes it's paired with another prime factor in this case, but not all cases.
 
@JerryCoffin Checking for primality is a pretty big thing to overlook; the whole strength of a sieve is that you don't have to resort to such things
 
As far are how you'd check whether it's prime, you should have a table handy that could check that.
@MooingDuck Yes -- one (and ONLY one) prime factor greater than sqrt(N).
@KaliMa Not at all -- the strength of a sieve is that it makes checking whether it's prime utterly trivial.
 
@JerryCoffin oh, more than one. misread. Hmmm.
 
if you have to sieve and then check for primality, there's no point
you don't need a primality tester
you can insert and be done with it
i already brought up an example why the sqrt(N) approach doesn't work. you also get duplicates
so you're not only needing to check the lists over and over and over again to see if you've already inserted something, but you also have to check if it's prime
 
6:09 PM
@KaliMa If you don't mind wasting a lot of space to accomplish nearly nothing you can. That doesn't invalidate a better approach.
 
that's a lot of extra operation
 
@JerryCoffin I figured out the logic. Makes sense. I agree.
@KaliMa sieve never gets duplicates
 
it does (6 is a good example)
 
@KaliMa No, it's not. I'll repeat, since you seemed to miss it: as soon as you find one prime factor larger than sqrt(N), you're done. In the end, there can only be one.
 
I'll give you an example jerry
 
6:11 PM
@KaliMa he's right, once the sieve we discussed finds a prime factor greater than or equal to the square root of the maximum number, you can stop.
 
i=2. insert 2 into 2, don't insert 2/1. insert 2 into 4, don't insert 4/2. insert 2 into 6, also insert 6/2. inset 2 into 8, don't insert 8/2. insert 2 into 10, also insert 10/2.
correct so far?
 
@KaliMa no. Use the sieve that you and I discussed and agreed on. All that changes is deciding when to stop. Which is the first prime greater than or equal to the square root of the maximum.
 
how would you modify the example i just gave
 
@R.MartinhoFernandes Done.
 
6:20 PM
still holds for 19 too: ideone.com/xCMPow
(I stopped at 19, because at 20 I have to handle double digit primes)
 
@MooingDuck Yes -- 19 is prime, which you know as soon as you reach sqrt(19) and haven't found a factor.
 
so the difference is: if you only need to find primes you only need to iterate to sqrt(max). But if you need all the prime factors of a number, need to go to (max/2).
no wait... you don't...
I GET IT NOW
because for indecies > sqrt(max), you can switch to the division shortcut.
 
what?
so you don't insert i and then also insert j/i?
only if j>sqrt(N)?
is that what you are saying?
no that doesn't work either
you can't use sqrt(N) approach
without a lot of extra operation
 
ideone.com/nR5uj2 you're right, it does put in duplicates, but that's very easily solved.
 
so you stop AFTER the sqrt(N) threshold?
even though 5 is > sqrt(19) you don't apply division trick there?
 
6:32 PM
not certain about numbers very close to the sqrt
if the number is equal to the square root you have to sieve still
ah, and 4 was less, so I continued. Technically 5 can be on either side, makes no difference I think.
yeah, 5 should have been on the division side.
You can sieve the whole thing, but the division thing is far faster.
 
ok so when <=sqrt(N), no division trick correct?
 
right
k, I added how I think the division step should work to ideone.com/nR5uj2
 
so i don't understand, this is just two loops right?
outer loop i=1 to sqrt(N)
inner loop is j=i to N
stepwise i
 
@KaliMa that's how the sieve part works yes.
 
Dumb question, what string does one use in C++11 to store unicode litterals?
 
6:40 PM
Then after that is _complete_, then you do the division part.
loop i = ciel(sqrt(N)) to i<N
 
hm seems to work but i get duplicates
 
@Borgleader depends on the type of the unicode literal
@KaliMa you have to remove the duplicates in the division step yes
@Borgleader for u8, it uses const char[N].
 
and i get nonprimes still even with the sqrt trick
 
@KaliMa you shouldn't be getting nonprimes. At no point should a nonprime be added to anything
 
i am trying N=100 and i get nonprimes
 
6:42 PM
It's just I saw a question about storing/displaying a string with Hindi characters in it. I assume this can be done using unicode? (since they're not part of ascii)
 
@Borgleader sure. There's several ways to do it. saving the file as any encoding that holds the characters you want, or using unicode literals of either utf8, utf16, or utf32.
 
@Mooing loop i=2 to <=sqrt(N). inside this loop, if factors[i] is empty, then we loop j=i to <=N, stepwise i, inserting into factors[j] the number i. If j happens to be >sqrt(N), also insert j/i.
correct?
 
@KaliMa what? no. That's not how the division thing works. Hold on.
 
@MooingDuck Sorry I wasn't clear, storing as string was std::wstring s = L"भाषाओं"; (Taken from the original question)
 
@Borgleader oh right, there's that too. That's a wide string literal const wchar_t[4] (in an implementation defined encoding) then stuffed into a std::wstring (in same said encoding)
 
6:53 PM
@MooingDuck What about that algorithm is wrong?
 
A colleague of mine's way of saying "database" suspiciously sounds like "databalls".
 
@KaliMa the division thing comes after you have stopped sieving altogether. It is a completely separate loop. Also, the division part is wrong entirely.
 
@EtiennedeMartel Then change the subject to space bases and pronouce it Spaceballs :P
 
oh so you only do the i to sqrt then insert plainly for j to N
right?
and then some extra process after that
 
@Borgleader I must have seen this movie like 25 times or something.
 
6:58 PM
I've only seen bits of it.
 

« first day (781 days earlier)      last day (4165 days later) »