Series of long Integers

Series of long Integers

write a program to print the series of long integer number?

Write a program in java to find out whether the given number is prime or not

View Answers

December 24, 2010 at 11:54 AM

Hello Friend,

1)Fibonacci series:

import java.util.*;

public class Fibonacci {
public static void main(String[] args) throws Exception {
Scanner input=new Scanner(System.in);
System.out.print("Enter value of n: ");
    int num = input.nextInt();
    int f1=0,f2=0,f3=1;
    for(int i=1;i<=num;i++){
        System.out.println(f3);
        f1=f2;
        f2=f3;
        f3=f1+f2;
    }
}
}

2)Check Prime Number

import java.util.*;

class  CheckPrimeNumber
{
    static boolean isPrime(int number){
          boolean isPrime=false;
          int i=(int) Math.ceil(Math.sqrt(number));
          while (i>1){
             if ((number!=i) && (number%i==0)){
                isPrime=false;
                break;
             }
             else if (!isPrime)
             isPrime=true;
             --i;
          }
          return isPrime;
       }
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.println("Enter Number:");
        int num=input.nextInt();
        if(isPrime(num)){
            System.out.println("Number is Prime!");
        }
        else{
            System.out.println("Number is not prime!");
        }
    }
}

Thanks









Related Tutorials/Questions & Answers:
Series of long Integers
Series of long Integers  write a program to print the series of long integer number? Write a program in java to find out whether the given number is prime or not   Hello Friend, 1)Fibonacci series: import java.util.
integers
integers  an application that finds the smallest of several integers. assume the first value read specifies the number of values to input from the user. please help
Advertisements
INTEGERS
application that will input the kms driven and litre of fuel used (both as integers
series
series  series 2-4+6-8+..............-20
series
series   s=1/a+2/a^2+2/a^3+3/a^3+.........n   logic is :-> long sum=0; for(int i=1;i<=n;i++){ sum=sum+i/(math.pow(a,i)) } System.out.println("sum:"+sum
Sum of integers
the user and displays i) the sum of all even integers between 1 and the input value, both inclusive. ii) The sum of all odd integers between 1 and the input value both inclusive Example: User enters 7. Sum of even integers = 2+4+6 = 12 Sum
integers
series printing
series printing  Question:- write a program to print the following series:- 0,1,3,6,15,21,28
series printing
series printing  Question:- write a program to print the following series:- 0,1,3,6,15,21,28
long validate
long validate  How to validate long type
SERIES PROGRAMMING
SERIES PROGRAMMING  WAP to print the followin series till n terms: S = 1-4+9-16+25.............n
Integers separated by a ", " in a string
Integers separated by a ", " in a string  How do I get integers separated by a ', ' in C++ in a string? Ex. string=1, 2, 3; //something to find the integers and put them in array a cout< output: 123   Hi Friend
Series Program
Series Program  Please help me to write code for this series Write a Java Method to solve the following problem: a.Evaluate the result of the series: 1-2+3-4+5-6+ââ?¬Â¦Ã¢â?¬Â¦+n (or ââ?¬â??n depending on value of n
sum of the series
sum of the series  Program to sum the series 1+1/1!+1/2!+1/3!+....n
ModuleNotFoundError: No module named 'artisinal_integers'
ModuleNotFoundError: No module named 'artisinal_integers'  Hi, My... named 'artisinal_integers' How to remove the ModuleNotFoundError: No module named 'artisinal_integers' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'artisinal_integers'
ModuleNotFoundError: No module named 'artisinal_integers'  Hi, My... named 'artisinal_integers' How to remove the ModuleNotFoundError: No module named 'artisinal_integers' error? Thanks   Hi, In your
Series Program
Series Program  Please help me to write code for this series Write a Java Method to solve the following problem: a.Evaluate the result of the series: 1-2+3-4+5-6+â?¦â?¦+n   hi friend, Try the following code may
series
LOOP-HOLE SERIES GENERATION
LOOP-HOLE SERIES GENERATION  QUESTION:- WRITE A PROGRAM TO GENERATE THE FOLLOWING SERIES CALLED LOOPHOLE SERIES:- 3,5,53,13,19,7,19,13,53,5,3
LOOP-HOLE SERIES GENERATION
LOOP-HOLE SERIES GENERATION  QUESTION:- WRITE A PROGRAM TO GENERATE THE FOLLOWING SERIES CALLED LOOPHOLE SERIES:- 3,5,53,13,19,7,19,13,53,5,3
ModuleNotFoundError: No module named 'series'
ModuleNotFoundError: No module named 'series'  Hi, My Python... 'series' How to remove the ModuleNotFoundError: No module named 'series'... to install padas library. You can install series python with following command
java programming:generating series
java programming:generating series  WAP to print series: | + || + ||| + |||| + .......... n terms
TIME SERIES DOUBT
TIME SERIES DOUBT  HI.................... In my project i am using the xydataset code to show the series output or graph say. In that each series has color taken by it on itself by default means first series has red then yellow
Maven Repository/Dependency: com.almworks.integers | integers
Maven Repository/Dependency of Group ID com.almworks.integers and Artifact ID integers. Latest version of com.almworks.integers:integers dependencies. # Version Release Date 1
Version of com.intersult>series dependency
List of Version of com.intersult>series dependency
Time series sorce code
Time series sorce code   hi.......... I want to show the output of my project as time series. Can u give me a simple code for time series. Where i... series forecasting the future......... source code in java swings. ? plz help
Time series sorce code
Time series sorce code   hi.......... I want to show the output of my project as time series. Can u give me a simple code for time series. Where i... series forecasting the future......... source code in java swings. ? plz help
fibonacci series logics
fibonacci series logics  A form contains 20 text fields, these fields.... Now we have fibonacci series number by which we have to find that numbers inserted by the user in fibonacci series or nearby. for each text field value. and show
how to find the sum of integers in a string of sentence in java
how to find the sum of integers in a string of sentence in java  how to find the sum of integers in a string of sentence in java for e.g:--> abc d 2 3 21 the output should be 2+3+21=26 (adsbygoogle
java matching array of integers - Java Beginners
token is assigned a vlaue in integers and stored in an array. the consecutive array of integers occurring similarly have to be found out. and depending upon... for finding similar consecutive array of integers
how to find [count the number of integers whose value is less than the average value of the integers]
how to find [count the number of integers whose value is less than the average value of the integers]  Construct an algorithm that will prompt... amount to the screen integers from an operator at a terminal, and count the number
HOW TO SHOW TIME SERIES
HOW TO SHOW TIME SERIES  hi................ i require a small code in java swings to display the output as time series. Can u plz help???????? Reply....... thanks in advance
Printing the integers before and after - JSP-Servlet
Printing the integers before and after  Hi, I'm trying to print out the integers before and after generated random number, and also stating it as either even or odd, but it does not seem to work. Pls advise on my code below
string to long in javascript
string to long in javascript  how to parse string to long in JavaScript?   To parse string to long you can use either parseInt or parseFloat in JavaScript.   parseint in javascript var s = ''; var num
sum of fibonacci series
sum of fibonacci series  Write a Java program to print Fibonacci series upto n and find their sum also. 0+1+1+2+3+5+8+13+21ââ?¬Â¦Ã¢â?¬Â¦Ã¢â?¬Â¦Ã¢â?¬Â¦=sum   Hi, Please see the thread Fibonacci program
Program to read 2 integers using oops concepts
Program to read 2 integers using oops concepts  Write a program to read two integers with the following significance. ? The first integer value represents a time of day on a 24 hour clock, so that 1245 represents quarter
How to create a long array with the help of long buffer.
How to create a long array with the help of long buffer.  In this tutorial, we will see how to create a long array with the help of long buffer...)  The allocate(..) method allocate a long buffer of given capacity
java programming:generating series
java programming:generating series  Write a program to generate series: 12345 1234 123 12 1 1 12 123 1234 12345 12345   Here is a code that displays the following pattern: 12345 1234 123 12 1 1 12 123 1234
printing series in java
printing series in java  1 123 12345 1234567 12345 123 1   Here is a code for the following pattern: 1 123 12345 1234567 12345 123 1 class Pattern{ public static void main(String[] args
ModuleNotFoundError: No module named 'linear_series'
ModuleNotFoundError: No module named 'linear_series'  Hi, My... 'linear_series' How to remove the ModuleNotFoundError: No module named 'linear_series' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pelican-series'
ModuleNotFoundError: No module named 'pelican-series'  Hi, My... named 'pelican-series' How to remove the ModuleNotFoundError: No module named 'pelican-series' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'series-renamer'
ModuleNotFoundError: No module named 'series-renamer'  Hi, My... named 'series-renamer' How to remove the ModuleNotFoundError: No module named 'series-renamer' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'shyft.time-series'
ModuleNotFoundError: No module named 'shyft.time-series'  Hi, My... named 'shyft.time-series' How to remove the ModuleNotFoundError: No module named 'shyft.time-series' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'time-series'
ModuleNotFoundError: No module named 'time-series'  Hi, My Python... 'time-series' How to remove the ModuleNotFoundError: No module named 'time-series' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'tv-series'
ModuleNotFoundError: No module named 'tv-series'  Hi, My Python...-series' How to remove the ModuleNotFoundError: No module named 'tv-series' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'Ella-Series'
ModuleNotFoundError: No module named 'Ella-Series'  Hi, My Python... 'Ella-Series' How to remove the ModuleNotFoundError: No module named 'Ella-Series' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'Fibonacci-Series'
ModuleNotFoundError: No module named 'Fibonacci-Series'  Hi, My... named 'Fibonacci-Series' How to remove the ModuleNotFoundError: No module named 'Fibonacci-Series' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'kisters.water.time-series'
ModuleNotFoundError: No module named 'kisters.water.time-series'  Hi...: No module named 'kisters.water.time-series' How to remove the ModuleNotFoundError: No module named 'kisters.water.time-series' error? Thanks  
Create a long buffer by wrapping an long array.
Create a long buffer by wrapping an long array.  In this tutorial, we will see how to create a long buffer by wrapping an long array into a buffer... Method Description static LongBuffer wrap(long[] array
How to transfer the value of a long  array into long buffer.
How to transfer the value of a long  array into long buffer.  ... into long buffer. LongBufferAPI: The java.nio.LongBuffer class extends... allocate(int capacity)  The allocate(..)method allocate a new long

Ads