Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 122293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:06:21+00:00 2026-05-11T04:06:21+00:00

problem euler #5 i found the solution but i don’t know why this first

  • 0

problem euler #5

i found the solution but i don’t know why this first code is faster (i put 14 in order to try to make more clear the code) the only difference is that i eliminate the for i wrote for a huge if

if($num%14==0 && $num%13==0 &&$num%12==0 &&$num%11==0 &&$num%10==0 && $num%9==0 && $num%8==0 && $num%7==0 && $num%6==0 && $num%5==0 && $num%4==0 && $num%3==0 && $num%2==0 && $num%1==0){     $notFound=0; } 

why is this second code hugely more slow than the first one? With the for it suppose to be faster. is the same in another languages???

$notFound=0; for ( $i=14; $i>=2 && notFound==0; $i--){     if($num%$i!=0){         $notFound=1;     } } 
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T04:06:22+00:00Added an answer on May 11, 2026 at 4:06 am

    The second code sample is simply performing more operations than the first, so I’d expect it to be slower. In this situation, you’d find that whilst offering poorer performance, a for loop offers significantly better readability and maintainability.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a Project Euler problem. If you don't want to see candidate solutions
This is fairly 'math-y' but I'm posting here because it's a Project Euler problem,
I did this problem [ Project Euler problem 5 ], but very bad manner
I am attempting Problem 20 on Project Euler and this is the solution that
I have this code written for a Project Euler problem in c++: int sum
This is actually a solution to Project Euler Problem 14 in F#. However, I'm
I have solved the project Euler problem 16 but discovered this rather novel approach
Here is a way to solve Euler problem 43 (please let me know if
I just solved the first problem from Project Euler in JavaFX for the fun
I am solving problem 9 on the Project Euler . In my solution I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.