编程介的小学生 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 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型