C language numerical algorithm