Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- float valoreAssoluto(float x){
- if(x>=0){
- return x;
- }else{
- return x*(-1.0);
- }
- }
- float radice(float a) {
- float x = 1.0;
- while (valoreAssoluto(x * x - a) > 1e-5)
- x = (x + a / x) / 2.0;
- return x;
- }
- float f(int n){
- return radice((n-1.0)/(n+1.0));
- }
- int main(){
- int a,b;
- printf("inserisci 2 numeri N \n");
- scanf("%d %d",&a,&b);
- while(a<=b){ // a<=x<=b
- if(a%2==0){
- printf("\n%f\n",f(a));
- }else{
- printf("\n %d\n",a);
- }
- a++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement