Wuhan University of Science and Technology acm:1005: Chinese Edition C language Programming tutorial (second Edition) example 5.8

Source: Internet
Author: User

Problem Description

The teacher gave a title to Xiao Hao: give you two integers x and n ( -10<=x<=10,1<=n<=10), let you find out the results of x^1+x^2+x^3+......+x^n. now that little Howe is in a quandary, please help him solve the problem.

Input

Enter two integers x and n per line.

Output

for each set of test data, the output line evaluates.

Sample Input
1 12 2
Sample Output
16
HINT
1#include <stdio.h>2 3 4 Long LongSumintXintN)5 {6 Long Longs=0;7     inti,j;8 Long LongS1;9      for(i=1; i<=n;i++)Ten     { Ones1=1; A          for(j=1; j<=i;j++) -         { -s1*=x; the         } -s+=S1; -     } -     returns; + } -  + intMain () A { at     intX,n; -      while(SCANF ("%d%d", &x,&n)! =EOF) -     { -printf"%lld\n", SUM (x,n)); -     } -      in     return 1; -}

Wuhan University of Science and Technology acm:1005: Chinese Edition C language Programming tutorial (second Edition) example 5.8

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.