Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Project Euler/Q5 Project Euler
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a prompt for the user to know what to enter (problem states 20)

for(int i=n;;i++)
{
int flag=1;
for(int j=1;j<=n;j++)
{
// int flag=1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this belongs here

if(i%j!=0)
{
flag=0;
break;
}
}
if(flag==1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a style thing but comparison to 1 is something many people don't want to see.

if (flag) is equivalent. (You're asking "is it true, that this is true?" instead of "is this true?")

{
printf("%d",i);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing linebreak at the end

break;
}
}
}