All pastes #2034822 Raw Edit

dpecka

public c v1 · immutable
#2034822 ·published 2010-12-31 04:40 UTC
rendered paste body
/* sample example: `gcc -o foo bar -lm`*	having inane equation n(n+sqrt(n))=L where:*	n increments as m=1; n=(++m)**2 .. so only integers are used*	the highest value of sqrt(n) is FF (255) so n could be up to 255**2**	you're getting L and need to determine n*	in example below we increments n and break() until we reach equality with L**	well, this code uses linear search which is NOT definitely very optimal*	foo() alse requires that only correct L will be passed ..*/#include <stdio.h>#include <math.h>#include <stdlib.h>unsigned foo(unsigned long long L){	unsigned m, n, l;	m = n = 1;	l = pow(255, 2);		for(n = 1; n <= l; n = pow(++m, 2)) {		if(n * (n + sqrt(n)) == L)			break;	};	return(n);}int main(void){	printf("%u\n", foo(2439853704));	exit(0);}