Skip to main content
Commonmark migration
Source Link

#C, 50 46 bytes

C, 50 46 bytes

i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}

Thanks to Neil and nwellnhof for saving 4 bytes!

Disappointingly long. I feel like there's some bit-shifting hack in here that I don't know about, but I can't find it yet. Returns a pointer to an array holding the three elements. Full program:

i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}

int main()
{
    int array[3];
    int n=10;
    f(array, n);
    printf("A:%d\tB:%d\tC:%d\n",array[0],array[1],array[2]);
    return 0;
}

#C, 50 46 bytes

i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}

Thanks to Neil and nwellnhof for saving 4 bytes!

Disappointingly long. I feel like there's some bit-shifting hack in here that I don't know about, but I can't find it yet. Returns a pointer to an array holding the three elements. Full program:

i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}

int main()
{
    int array[3];
    int n=10;
    f(array, n);
    printf("A:%d\tB:%d\tC:%d\n",array[0],array[1],array[2]);
    return 0;
}

C, 50 46 bytes

i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}

Thanks to Neil and nwellnhof for saving 4 bytes!

Disappointingly long. I feel like there's some bit-shifting hack in here that I don't know about, but I can't find it yet. Returns a pointer to an array holding the three elements. Full program:

i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}

int main()
{
    int array[3];
    int n=10;
    f(array, n);
    printf("A:%d\tB:%d\tC:%d\n",array[0],array[1],array[2]);
    return 0;
}
added 47 characters in body
Source Link
DJMcMayhem
  • 59.6k
  • 17
  • 196
  • 348

#C, 5050 46 bytes

fi;f(int*a,int n){for(int i=2;i<5;a[i-2]=n+ii=1;++i<5;*a++=n+i-n%i++n%i);}

Thanks to Neil and nwellnhof for saving 4 bytes!

Disappointingly long. I feel like there's some bit-shifting hack in here that I don't know about, but I can't find it yet. Returns a pointer to an array holding the three elements. Full program:

fi;f(int*a,int n){for(int i=2;i<5;a[i-2]=n+ii=1;++i<5;*a++=n+i-n%i++n%i);}

int main()
{
    int array[3];
    int n=10;
    f(array, n);
    printf("A:%d\tB:%d\tC:%d\n",array[0],array[1],array[2]);
    return 0;
}

#C, 50 bytes

f(int*a,int n){for(int i=2;i<5;a[i-2]=n+i-n%i++);}

Disappointingly long. I feel like there's some bit-shifting hack in here that I don't know about, but I can't find it yet. Returns a pointer to an array holding the three elements. Full program:

f(int*a,int n){for(int i=2;i<5;a[i-2]=n+i-n%i++);}

int main()
{
    int array[3];
    int n=10;
    f(array, n);
    printf("A:%d\tB:%d\tC:%d\n",array[0],array[1],array[2]);
    return 0;
}

#C, 50 46 bytes

i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}

Thanks to Neil and nwellnhof for saving 4 bytes!

Disappointingly long. I feel like there's some bit-shifting hack in here that I don't know about, but I can't find it yet. Returns a pointer to an array holding the three elements. Full program:

i;f(int*a,int n){for(i=1;++i<5;*a++=n+i-n%i);}

int main()
{
    int array[3];
    int n=10;
    f(array, n);
    printf("A:%d\tB:%d\tC:%d\n",array[0],array[1],array[2]);
    return 0;
}
Source Link
DJMcMayhem
  • 59.6k
  • 17
  • 196
  • 348

#C, 50 bytes

f(int*a,int n){for(int i=2;i<5;a[i-2]=n+i-n%i++);}

Disappointingly long. I feel like there's some bit-shifting hack in here that I don't know about, but I can't find it yet. Returns a pointer to an array holding the three elements. Full program:

f(int*a,int n){for(int i=2;i<5;a[i-2]=n+i-n%i++);}

int main()
{
    int array[3];
    int n=10;
    f(array, n);
    printf("A:%d\tB:%d\tC:%d\n",array[0],array[1],array[2]);
    return 0;
}