#include #include #include #include #include #include #include static u32 *xfb; static GXRModeObj *rmode; void Initialise() { VIDEO_Init(); WPAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(xfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); } void WaitForInput() { while (1) { WPAD_ScanPads(); u16 buttonsDown = WPAD_ButtonsDown(0); if (buttonsDown & WPAD_BUTTON_A) { break; } } } void spigot() { //https://craftofcoding.wordpress.com/tag/spigot-algorithm/ int i, j, k, q, x; int len, nines=0, predigit=0; int N=20000; //you can actually go way up but it makes the calculation slow len = (10*N/3)+1; int* a = malloc(len * sizeof(int)); if (a == NULL) { printf("Error allocating memory.\n"); return; } // Initialize A to (2,2,2,2,2,...,2) for (i=0; i0; i=i-1) { x = 10 * a[i-1] + q*i; a[i-1] = x % (2*i-1); q = x / (2*i-1); } a[0] = q % 10; q = q / 10; if (q == 9) nines = nines + 1; else if (q == 10) { printf("%d", predigit+1); for (k=0; k