Skip to content

Instantly share code, notes, and snippets.

@FredrikAugust
Created April 29, 2019 08:08
Show Gist options
  • Save FredrikAugust/3eda3d5464d8f6573c388cbc7a7b32a0 to your computer and use it in GitHub Desktop.
Save FredrikAugust/3eda3d5464d8f6573c388cbc7a7b32a0 to your computer and use it in GitHub Desktop.
/r/dailyprogrammer #376
#include<stdio.h>
int leaps(int from, int to)
{
int count(0);
for (; from < to; from++) {
if ((from % 100 != 0 || (from % 900 == 200 || from % 900 == 600)) && from % 4 == 0)
count++;
}
printf("%d -> %d => %d\n", from, to, count);
return count;
}
int main(int argc, char const *argv[])
{
leaps(2016, 2017);
leaps(2019, 2020);
leaps(1900, 1901);
leaps(2000, 2001);
leaps(2800, 2801);
leaps(123456, 123456);
leaps(1234, 5678);
leaps(123456, 7891011);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment