编程介的小学生 2019-06-17 15:57 采纳率: 20.5%
浏览 165

欧拉的方程用数列的计算问题,怎么使用C语言的程序的代码设计的过程来实现的呢?

Problem Description
The Euler function phi is an important kind of function in number theory, (n) represents the amount of the numbers which are smaller than n and coprime to n, and this function has a lot of beautiful characteristics. Here comes a very easy question: suppose you are given a, b, try to calculate (a)+ (a+1)+....+ (b)

Input
There are several test cases. Each line has two integers a, b (2<a<b<3000000).

Output
Output the result of (a)+ (a+1)+....+ (b)

Sample Input
3 100

Sample Output
3042

  • 写回答

1条回答 默认 最新

  • weixin_44481341 2019-06-17 18:43
    关注

    #include
    int main()
    {
    int i,j,k,a,b,sum,t,temp;
    sum=0;
    scanf("%d %d",&a,&b);
    for(i=a;i<=b;i++)
    { t=0;
    for(j=1;j<i;j++)
    { temp=1;
    for(k=2;k<=j;k++)
    {
    if(i%k==0&&j%k==0)
    { temp=0;
    break;
    }
    }
    if(temp==1)
    { t++;

         }
     }
     sum+=t;
    

    }
    printf("%d\n",sum);
    }

    这样就可以实现了
    
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题