473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to generate the series?

Ajay Bhalala
119 64KB
Hello all,

I want to generate the following series in the java

1!-2²+3!-4²+5!-6².....

How can I generate this series in Java?
Oct 4 '15 #1
2 1153
Luuk
1,047 Expert 1GB
OK, I have down half of your homework.....

Expand|Select|Wrap|Line Numbers
  1. class Series {
  2.             public static void main(String[] args) {
  3.                             System.out.println("Hello World!"); // Display the string.
  4.                             int x=1;
  5.                             double s=0;
  6.  
  7.                             while (x<10) {
  8.                                     s = s + factorial(x);
  9.                                     s = s - Math.pow((x+1),2);
  10.                                     x = x + 2;
  11.                                     System.out.println(s);
  12.                             }
  13.       }
  14.  
  15.       public static int factorial(int x) {
  16.               switch (x) {
  17.                       case 1: return 1;
  18.                       case 3: return 6;
  19.                       case 5: return 120;
  20.                       case 7: return 5040;
  21.                       case 9: return 362880;
  22.                       default: System.out.println("Create your own factorial function....."); return 0;
  23.               }
  24.       }
  25. }
  26.  
and i'm not even a java programmer......
Oct 4 '15 #2
Ajay Bhalala
119 64KB
Hi Luuk,

Thank you so much for your reply.

You have really realeased my tantion about this series. Thank you so much.
Oct 5 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Christopher M. Pieper | last post by:
I want to generate a resultset that is just a series of numbers in ascending order or perhaps a series of dates.. What I mean is, is there a way to generate a temporary table of dates given an...
0
by: Nick | last post by:
Hi all, I'm about to embark on a new project and can't decide quite how to do it. In summary, I have a database whose data I want to use to create html pages for a website. The website will just...
4
by: geoffp | last post by:
I need to generate reproducible random number series. I've done the obvious - use mt_srand with the same seed. This supposedly will create the same series every time. Is this true? Its not...
0
by: bikram3005181 | last post by:
How to generate series of charts dynamically ? I have report parameter called location which has 10 locations. on each selection of a location, one chart is shown. How to generate 10 charts for each...
2
by: Junior | last post by:
I'm using the 2.0 Wizard control to generate an RSS feed which consists of one channel and one or more items noting each item collects data from a series of steps. I need to learn a methodology to...
10
by: omran11 | last post by:
how to generate fibonacci series (lesser than 100)
4
by: Dave067 | last post by:
Hi Folks! I was trying to write some Python script to calculate resistor values for electronics projects, and wanted to generate lists of the preferred resistor values in each standard...
5
by: Anshu12 | last post by:
I want to generate series of numbers between two numbers (one is lower value and another is higher one) eg-My lower end value is 66660001 and higher end value is 66662000 then I want to generate all...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.