Skip to content

Instantly share code, notes, and snippets.

@PythonJedi
PythonJedi / kaprekar.c
Created November 8, 2017 05:48
Much faster implementation of Kaprekar's function
/*
* Attempt to find fixed points of a particularly interesting function.
*
* Kaprekar's function sorts the digits of n ascending and descending, then
* returns the descending minus the ascending. The fixed points of this
* function, as well as the attractor classes are very interesting.
*/
#include<stdio.h>
#include<limits.h>
@PythonJedi
PythonJedi / loop.c
Created February 27, 2018 18:04
infinipointer
#include<stdlib.h>
#include<stdio.h>
int main(int argv, char* argc[]) {
void** loop = malloc(sizeof(void**));
*loop = (void*) loop;
printf("loop: %p, *loop: %p\n", loop, *loop);
free(loop);