"C-Language Program" Valeo series

Source: Internet
Author: User

For any given natural number N, the irreducible true fraction of the denominator less than or equal to n is arranged in ascending order, and the first score is preceded by 0/1, followed by the last score plus 1/1, which is known as the N-level sequence of mines, denoted by FN. such as F5:0/1,1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5,1/1. The number of elements is 11.

Now give n lets you ask for the permutation and number of elements in the N-level sequence of lightning.

1#include <stdio.h>2#include <stdlib.h>3 intn,s;4 voidPreintAintBintCintD) {//using binary method to output the sequence of thunder5     if(b+d>n)return ;6Pre (a,b,a+c,b+d);7printf"%d/%d,", a+c,b+d);8Pre (a+c,b+d,c,d);9 }Ten     intEular (intN) {//using Euler function to find the number of N-Reciprocity One     Doublesum=N; A     inti; -      for(i=2; i<=n;i++){ -         if(n%i==0){ theSum*= (1-1.0/i); -              while(n%i==0){     -n=n/i; -             } +         } -     } +     return(int) sum; A } at intSUM (intN//Euler function Summation - { -     intj,sum=0; -      for(j=2; j<=n;j++) -sum+=Eular (j); - returnsum; in } -  to intMain () + {   -scanf"%d",&n); theprintf"0/1,"); *Pre0,1,1,1); $printf"1/1\n");Panax Notoginsengs=SUM (n); -printf"%d", s+2); the        +       return 0; A}

"C-Language Program" Valeo series

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.