Tính tổng của chuỗi trong chuyên gia gán Python

Chương trình tìm tổng của chuỗi 1 + x + x^2+ x^3+. +x^n

Cải thiện bài viết

Lưu bài viết

Thích bài viết

  • Độ khó. Trung bình
  • Cập nhật lần cuối. 12 tháng 7 năm 2022

  • Đọc
  • Bàn luận
  • khóa học
  • Luyện tập
  • Băng hình
  • Cải thiện bài viết

    Lưu bài viết

    Cho một số nguyên X, nhiệm vụ là in chuỗi và tìm tổng của chuỗi 


    Ví dụ.
     

    Đầu vào. X = 2, N = 5 
    Đầu ra. Tổng = 31 
    1 2 4 8 16
    Đầu vào. X = 1, N = 10 
    Đầu ra. Tổng = 10 
    1 1 1 1 1 1 1 1 1 1 
     

     

    Khuyến khích. Vui lòng thử cách tiếp cận của bạn trên {IDE} trước, trước khi chuyển sang giải pháp

    Cách tiếp cận. Ý tưởng là duyệt qua chuỗi và tính tổng N số hạng của chuỗi. Thuật ngữ thứ N của chuỗi có thể được tính là.
     

    Số hạng thứ N = [N-1]Số hạng * X 
     

    Dưới đây là cách triển khai của phương pháp trên.
     

    C++




    // C++ implementation to find

    // sum of series of

    // 1 + x^2 + x^3 + ....+ x^n

     

    #include

     

    using namespace std;

     

    ________số 8

    // the series and print N terms

    // C++ implementation to find0

    // C++ implementation to find1 // C++ implementation to find2// C++ implementation to find3 // C++ implementation to find4// C++ implementation to find3 // C++ implementation to find6

    // C++ implementation to find7

    // C++ implementation to find8// C++ implementation to find1 // sum of series of0

     

    // C++ implementation to find8// sum of series of2

    // C++ implementation to find8// sum of series of4// sum of series of5// sum of series of6

     

    // C++ implementation to find8// sum of series of8

    // C++ implementation to find8// 1 + x^2 + x^3 + ....+ x^n0

    // C++ implementation to find8// 1 + x^2 + x^3 + ....+ x^n2 // 1 + x^2 + x^3 + ....+ x^n3

     

    // 1 + x^2 + x^3 + ....+ x^n4// 1 + x^2 + x^3 + ....+ x^n5

    // 1 + x^2 + x^3 + ....+ x^n4// 1 + x^2 + x^3 + ....+ x^n7// sum of series of5// sum of series of6

    // 1 + x^2 + x^3 + ....+ x^n4#include 1

    // C++ implementation to find8#include 3

     

    // C++ implementation to find8#include 5#include 6// sum of series of6

    // C++ implementation to find8#include 9 using0

    #include 3

     

    using2

    // C++ implementation to find3 using4

    // C++ implementation to find7

    // C++ implementation to find8// C++ implementation to find3 using8

    // C++ implementation to find8// C++ implementation to find3 namespace1

    // C++ implementation to find8namespace3

    namespace4namespace5

    namespace4namespace7

    // C++ implementation to find8#include 9 std;0

    #include 3

    C




    std;2

    std;3

     

    std;4

    std;5

     

    std;6

    std;7

    // C++ implementation to find1 // C++ implementation to find2// C++ implementation to find3 // C++ implementation to find4// C++ implementation to find3 // C++ implementation to find6

    // C++ implementation to find7

    // C++ implementation to find8// C++ implementation to find1 // sum of series of0

     

    // C++ implementation to find8// Function to find the sum of9

    // C++ implementation to find8// the series and print N terms1// the series and print N terms2// the series and print N terms3// the series and print N terms4

     

    // C++ implementation to find8// the series and print N terms6

    // C++ implementation to find8// the series and print N terms8

    // C++ implementation to find8// 1 + x^2 + x^3 + ....+ x^n2 // 1 + x^2 + x^3 + ....+ x^n3

     

    // 1 + x^2 + x^3 + ....+ x^n4// 1 + x^2 + x^3 + ....+ x^n5

    _______34____91____92____107// C++ implementation to find08

    // 1 + x^2 + x^3 + ....+ x^n4#include 1

    // C++ implementation to find8#include 3

    // C++ implementation to find8// the series and print N terms1// the series and print N terms2#include 6// the series and print N terms4

    // C++ implementation to find8#include 9 using0

    #include 3

     

    // C++ implementation to find22

    // C++ implementation to find3 using4

    // C++ implementation to find7

    // C++ implementation to find8// C++ implementation to find3 using8

    // C++ implementation to find8// C++ implementation to find3 namespace1

    _______18____91____92____135// C++ implementation to find36

    // C++ implementation to find8#include 9 std;0

    #include 3

    Java




    // C++ implementation to find41

    // C++ implementation to find42

    // 1 + x^2 + x^3 + ....+ x^n

     

    // C++ implementation to find44 // C++ implementation to find45

     

    // C++ implementation to find8// C++ implementation to find47

    // C++ implementation to find8// C++ implementation to find0

    // C++ implementation to find8// C++ implementation to find51 // C++ implementation to find1 // C++ implementation to find2// C++ implementation to find3 // C++ implementation to find4// C++ implementation to find3 // C++ implementation to find6

    // C++ implementation to find8// C++ implementation to find7

    // 1 + x^2 + x^3 + ....+ x^n4// C++ implementation to find1 // C++ implementation to find62____163// C++ implementation to find64

     

    // 1 + x^2 + x^3 + ....+ x^n4// sum of series of2

    _______34____168____93// the series and print N terms4

     

    // 1 + x^2 + x^3 + ....+ x^n4// sum of series of8

    // 1 + x^2 + x^3 + ....+ x^n4// C++ implementation to find74

    // 1 + x^2 + x^3 + ....+ x^n4// C++ implementation to find76

    // 1 + x^2 + x^3 + ....+ x^n4// 1 + x^2 + x^3 + ....+ x^n2 // C++ implementation to find79____180// C++ implementation to find81

    // C++ implementation to find82// 1 + x^2 + x^3 + ....+ x^n5

    // C++ implementation to find82// C++ implementation to find85

    // C++ implementation to find82// C++ implementation to find68// sum of series of5// the series and print N terms4

    // C++ implementation to find82#include 1

    // 1 + x^2 + x^3 + ....+ x^n4#include 3

     

    // 1 + x^2 + x^3 + ....+ x^n4// C++ implementation to find95

    // 1 + x^2 + x^3 + ....+ x^n4#include 9 using0

    // C++ implementation to find8#include 3

     

    // C++ implementation to find8// C++ implementation to find22

    // C++ implementation to find8// sum of series of04 // C++ implementation to find51 // sum of series of06 // sum of series of07

    // C++ implementation to find8// C++ implementation to find7

    // 1 + x^2 + x^3 + ....+ x^n4// C++ implementation to find3 // sum of series of12____213// sum of series of6

    // 1 + x^2 + x^3 + ....+ x^n4// C++ implementation to find3 // sum of series of17____218// sum of series of6

    // 1 + x^2 + x^3 + ....+ x^n4____221

    ________ 182 ________ 135 ________ 136

    // C++ implementation to find8#include 3

    #include 3

    Python3




    // sum of series of28

    // sum of series of29

     

    // sum of series of30

    // sum of series of31

    // sum of series of32

    // sum of series of33 // sum of series of34// sum of series of35

    // C++ implementation to find8

    // C++ implementation to find8// sum of series of38// sum of series of39 // C++ implementation to find63

    // C++ implementation to find8// sum of series of42____239 // sum of series of44

     

    // C++ implementation to find8// sum of series of46

    // C++ implementation to find8// sum of series of48// the series and print N terms2// C++ implementation to find80// sum of series of51// sum of series of39 // sum of series of5// sum of series of54

     

    // C++ implementation to find8// sum of series of56

    // C++ implementation to find8// sum of series of58

    // C++ implementation to find8// 1 + x^2 + x^3 + ....+ x^n2 // sum of series of61// sum of series of62 // sum of series of63// the series and print N terms2// C++ implementation to find80// sum of series of66

    // 1 + x^2 + x^3 + ....+ x^n4

    // 1 + x^2 + x^3 + ....+ x^n4// sum of series of38____239 // sum of series of38// sum of series of72 // sum of series of42

    // 1 + x^2 + x^3 + ....+ x^n4// sum of series of48______92// sum of series of77 // sum of series of78 // sum of series of79// sum of series of39 // sum of series of5// sum of series of54

    // 1 + x^2 + x^3 + ....+ x^n4// sum of series of42// sum of series of39 // sum of series of42// sum of series of87 // sum of series of44

    // 1 + x^2 + x^3 + ....+ x^n4

    // C++ implementation to find8// sum of series of48// the series and print N terms2// sum of series of93// sum of series of54

    // C++ implementation to find8#include 9 using0

     

    // sum of series of98

    // sum of series of44// sum of series of39 // sum of series of13

    // 1 + x^2 + x^3 + ....+ x^n02// sum of series of39 // sum of series of18

    // sum of series of48// the series and print N terms2// 1 + x^2 + x^3 + ....+ x^n07 // sum of series of78 // sum of series of34// 1 + x^2 + x^3 + ....+ x^n10

     

    // 1 + x^2 + x^3 + ....+ x^n11

    C#




    // 1 + x^2 + x^3 + ....+ x^n12

    // C++ implementation to find42

    // 1 + x^2 + x^3 + ....+ x^n

    using // 1 + x^2 + x^3 + ....+ x^n16

    // C++ implementation to find44 // 1 + x^2 + x^3 + ....+ x^n18

     

    // 1 + x^2 + x^3 + ....+ x^n19

    // C++ implementation to find0

    // C++ implementation to find51 // C++ implementation to find1 // C++ implementation to find2// C++ implementation to find3 // C++ implementation to find4// C++ implementation to find3 // C++ implementation to find6

    // C++ implementation to find7

    // C++ implementation to find8// C++ implementation to find1 // sum of series of0

     

    // C++ implementation to find8// sum of series of2

    // C++ implementation to find8// 1 + x^2 + x^3 + ....+ x^n35// the series and print N terms3// the series and print N terms4

     

    // C++ implementation to find8// sum of series of8

    // C++ implementation to find8// C++ implementation to find74

    // C++ implementation to find8// C++ implementation to find76

    // C++ implementation to find8// 1 + x^2 + x^3 + ....+ x^n2 // 1 + x^2 + x^3 + ....+ x^n46

    // C++ implementation to find8// C++ implementation to find7

    // 1 + x^2 + x^3 + ....+ x^n4// 1 + x^2 + x^3 + ....+ x^n5

    // 1 + x^2 + x^3 + ....+ x^n4// 1 + x^2 + x^3 + ....+ x^n52

    // 1 + x^2 + x^3 + ....+ x^n4// 1 + x^2 + x^3 + ....+ x^n35____25// the series and print N terms4

    // 1 + x^2 + x^3 + ....+ x^n4#include 1

    // C++ implementation to find8#include 3

    // C++ implementation to find8// 1 + x^2 + x^3 + ....+ x^n62

    // C++ implementation to find8#include 9 using0

    #include 3

     

    // C++ implementation to find22

    // sum of series of04 // C++ implementation to find51 // sum of series of06 // 1 + x^2 + x^3 + ....+ x^n71

    // C++ implementation to find7

    // C++ implementation to find8// C++ implementation to find3 using8

    // C++ implementation to find8// C++ implementation to find3 namespace1

    // C++ implementation to find8// 1 + x^2 + x^3 + ....+ x^n35// 1 + x^2 + x^3 + ....+ x^n81// C++ implementation to find36

    #include 3

    #include 3

     

    // 1 + x^2 + x^3 + ....+ x^n85

    Javascript




    // 1 + x^2 + x^3 + ....+ x^n86

    // 1 + x^2 + x^3 + ....+ x^n87

    // sum of series of

    // 1 + x^2 + x^3 + ....+ x^n

     

    ________số 8

    // the series and print N terms

    // C++ implementation to find0

    // 1 + x^2 + x^3 + ....+ x^n93 // 1 + x^2 + x^3 + ....+ x^n94

    // C++ implementation to find7

    // C++ implementation to find8// 1 + x^2 + x^3 + ....+ x^n97

     

    // C++ implementation to find8// sum of series of2

    // C++ implementation to find8#include 01____25// the series and print N terms4

     

    // C++ implementation to find8// sum of series of8

    // C++ implementation to find8// 1 + x^2 + x^3 + ....+ x^n0

    // C++ implementation to find8// 1 + x^2 + x^3 + ....+ x^n2 // 1 + x^2 + x^3 + ....+ x^n3

     

    // 1 + x^2 + x^3 + ....+ x^n4// 1 + x^2 + x^3 + ....+ x^n5

    _______34____414____25____94

    // 1 + x^2 + x^3 + ....+ x^n4#include 1

    // C++ implementation to find8#include 3

     

    // C++ implementation to find8#include 22____423// the series and print N terms4

    // C++ implementation to find8#include 9 using0

    #include 3

     

    using2

    // C++ implementation to find8#include 31

    // C++ implementation to find8#include 33

    // C++ implementation to find8#include 35

     

    #include 36

    #include 37

    đầu ra.

    1 2.0 4.0 8.0 16.0 
    31.00

     

    Thời gian phức tạp. Trên]

    Không gian phụ trợ. O[1], vì không có khoảng trống thừa nào được sử dụng


    Ghi chú cá nhân của tôi arrow_drop_up

    Tiết kiệm

    Vui lòng Đăng nhập để nhận xét.

    Chủ Đề