Created
November 16, 2016 09:32
-
-
Save sjmulder/1d947035d31036be75e3bbca0967b81c to your computer and use it in GitHub Desktop.
Pascal’s triangle using vector additions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#define N 64 | |
#define VECSZ ((N+1)/2) | |
int main(int argc, const char* argv[]) | |
{ | |
uint64_t vec[VECSZ] = {1}; | |
for (int i = 1; i < N; i++) | |
for (int j = min(i, VECSZ-1); j > 0; j--) | |
vec[j] += vec[j-1]; | |
for (int i = 0; i < VECSZ; i++) printf("%llu\n", vec[i]); | |
for (int i = N/2-1; i >= 0; i--) printf("%llu\n", vec[i]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment