[Solved] Series 2 with C++, Python, Java

Series 2: The Event Organizing Company “Buzzcraft” focuses event management in a way that creates a win-win situation for all involved stakeholders. Buzzcraft don’t look at building one time associations with clients, instead, aim at creating long-lasting collaborations that will span years to come. This goal of the company has helped them evolve and expand big with more workforces within notable time.
The number of employees of the company from the start day of their journey till now is recorded sensibly and is seemed to have followed a specific series like: 20, 60, 104, 152, 204,…….

Write a program which takes an integer N as the input and will output the series till the Nth term.

Input Format:
First line of the input is an integer N.

Output Format:
Output a single line the series till Nth term, each separated by a comma.
Refer sample input and output for formatting specifications.

Sample Input 1:
5

Sample Output 1:
20 60 104 152 204

Sample Input 2:
10

Sample Output 2:
20 60 104 152 204 260 320 384 452 524

Solution

#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int i = 1;
    while (i <= n)
    {
        cout << (2 * i * i + 34 * i - 16) << " ";
        i++;
    }
    return 0;
    // sauravhathi
}
import java.util.Scanner;
public class Series2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i = 1;
        while (i <= n) {
            System.out.print(2 * i * i + 34 * i - 16 + " ");
            i++;
        }
    }
    // sauravhathi
}
n = int(input())
for i in range(1, n + 1):
    print(2 * i * i + 34 * i - 16, end=" ")
    # sauravhathi

Happy Learning – If you require any further information, feel free to contact me.

Share your love
Saurav Hathi

Saurav Hathi

I'm currently studying Bachelor of Computer Science at Lovely Professional University in Punjab.

📌 Nodejs and Android 😎
📌 Java

Articles: 444

Leave a Reply

Your email address will not be published. Required fields are marked *