Skip to content

Instantly share code, notes, and snippets.

@cohalz
Created October 1, 2013 04:41
Show Gist options
  • Save cohalz/6773941 to your computer and use it in GitHub Desktop.
Save cohalz/6773941 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(){
int i,n;
float c;
printf("c = ");
if(scanf("%f", &c) != 1 || c < 2) {
puts("Wrong input.");
return 1;
}
printf("n = ");
if(scanf("%d", &n) != 1 || n < 1) {
puts("Wrong input.");
return 1;
}
printf("c1=%f\n",c);
for(i=2;i<=n;i++){
c = (c*c+2)/(2*c);
printf("c%d=%f\n",i,c);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment