Prime number calculation fun

前端 未结 18 1810
深忆病人
深忆病人 2020-12-05 15:32

We\'re having a bit of fun here at work. It all started with one of the guys setting up a Hackintosh and we were wondering whether it was faster than a Windows Box of (nearl

18条回答
  •  长情又很酷
    2020-12-05 15:41

    Does the re-declaration of the variable prime

            while (count < topPrime) {
    
                boolean prime = true;
    

    within the loop make it inefficient? (I assume it doesn't matter, since I would think Java would optimize this)

    boolean prime;        
    while (count < topPrime) {
    
                prime = true;
    

提交回复
热议问题