i dont no how to solve it pls

i dont no how to solve it pls

Calculate and display the sum of all prime number from 1 to 100 covert in java system codes

View Answers

December 15, 2010 at 3:38 PM

Hi Friend,

Try the following code:

class PrimeNumbers{
public static void main (String args[]){
String primeNo = "";
int sum=0;
int j=0;
System.out.println("Prime nums are:" );
for (int i = 1; i < 100; i++){ {
for ( j = 2; j < i; j++){
if (i % j == 0) {
break;
}
}
if (i == j) {
primeNo += i + " ";
sum+=i;
}
}
}
System.out.println(primeNo);
System.out.println("Sum of Prime Numbers: "+sum);
}
}

Thanks


December 27, 2010 at 4:54 PM

Hi friend Try this code.......

import java.io.;
class today2
{
public static void main(String args[])throws IOException
{
BufferedReader obg=new BufferedReader(new InputStreamReader(System.in));
String str=obg.readLine();
int num=Integer.parseInt(str);
int sum=0;
//int  test=5;
       for(int i=2;i&lt;=num;i++)
                {
     if(num%i==0)
             {
      sum=sum+i;
              }
     }
System.out.println("Result"+sum);
}
}









Related Tutorials/Questions & Answers:
i dont no how to solve it pls
i dont no how to solve it pls   Calculate and display the sum of all prime number from 1 to 100 covert in java system codes
PureStack question---i dont know how to do this
PureStack question---i dont know how to do this  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from... the queue g. H and I join the queue h. G leaves the queue i. H and I leave
Advertisements
PureStack question---i dont know how to do this
PureStack question---i dont know how to do this  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from... the queue g. H and I join the queue h. G leaves the queue i. H and I leave
how do i solve this problem?
how do i solve this problem?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access
how do i solve this question?
how do i solve this question?  1.Define a class named Circle with the following properties: a) An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier
how should i can solve
how should i can solve  Web based program - Input - Person's contact details with Passport Number as Unique Key. Save data in to oracle / MySQL. Output - List of Persons saved in the database. Technology to be used - JSP
one error but i dont know how to fix it o_O!!!
one error but i dont know how to fix it o_O!!!  where is the mistake here ?? import java.utill.Scanner; public class Time { public static void main (String [] args) { Scanner keyboard = new Scanner (System.in
how can i get output pls urget tell me
how can i get output pls urget tell me  HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception
I couldn't solve it
I couldn't solve it  *A customer who wants to apply for getting a car license should provide information about the brand of the car. *Then the customer receives a request ID from the office. *The customer's request (represented
pls i need help with my assignment
pls i need help with my assignment  how to write a code that ask the user for the height of the triangle and prints the triangle using * eg if height is 3 it prints * and also using import java.util.Scanner
how to solve
how to solve   log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources). log4j:WARN Please initialize the log4j system properly
i need help to solve this problem
i need help to solve this problem  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from standard input.... H and I join the queue h. G leaves the queue i. H and I leave the queue
how to solve this..
how to solve this..  Given a list of students and their marks Name | Science | Math | English | Computer Ahmad | 28 | 100 | 66 | 34 Samad | 56 | 89 | 55
how to solve this..
how to solve this..  Given a list of students and their marks Name | Science | Math | English | Computer Ahmad | 28 | 100 | 66 | 34 Samad | 56 | 89 | 55
how to solve an internet connection problem
how to solve an internet connection problem  when i run my..." java.lang.UnsupportedOperationException: Not yet implemented the problem is that i don`t know how to implement
hi.. i hv few error. pls. - Java Beginners
hi.. i hv few error. pls.  hi sir, i have few error. can u pls help me. pls. im very new in java. ths my Uni assgmnt. please help me... import...(""); System.out.println("\t "+title[i]+"\t
i have a problem to do this question...pls help me..
i have a problem to do this question...pls help me..  Write a program... reversedNumber = 0; for (int i = 0; i <= num; i...; reversedNumber = reversedNumber * 10 + r; i = 0
How to solve the Hibernate Common Exceptions?
How to solve the Hibernate Common Exceptions?  How to solve the Hibernate Common Exceptions
i want to retriev and update in same form but its not working pls help....
i want to retriev and update in same form but its not working pls help....  <p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html></p> <p>
Solve it
Solve it  How to calculate the value which contains oparator and operand both using command line argument
How to Solve the Syntax Error in java??
How to Solve the Syntax Error in java??  Syntax error in java? i have... on token "i", VariableDeclarator expected after this token" . in last line of the program "objectname.i" What is the reason for this error??How to access the variable
solve this pbm
solve this pbm  sir rows are also inserting i have checked in the database also the rows are not affected in the table . The first pbm wich i have sent to you is not yet solved.......... pls give me detail explaination how we
Want to add a resource in the build directory that's created when i run an mvn assembly:assembly command. Pls help!
Want to add a resource in the build directory that's created when i run an mvn assembly:assembly command. Pls help!  I have got a certificate in my resource folder-> src/main/resources/cacerts. When I do a mvn assembly
how to solve the nullPointer Exception in main - Java Beginners
how to solve the nullPointer Exception in main  New to Java ,pls help me how fix Null pointer Exception in main: two files , split .java another is actualState1.java , I want to get value of spaceWord[1] from split.java
how to solve this problem for oracle connectivity
how to solve this problem for oracle connectivity  Exception in thread "main" java.sql.SQLException: Io exception: The Network Adap ter could not establish the connection
how to solve 'Stop Running This Script' Error ?
how to solve 'Stop Running This Script' Error ?  Hi.. When opened the page on IE browser(version : 8.0),it gives an java script error (i.e.Stop Running This Script). I have used jsp/servlet for this. Please help to resolved
How to solve ModuleNotFoundError: No module named 'paramiko' error
How to solve ModuleNotFoundError: No module named 'paramiko' error  Hi, while importing following module: import paramiko I am getting the error... 'paramiko' How to solve ModuleNotFoundError: No module named 'paramiko' error
How to solve ModuleNotFoundError: No module named 'paramiko' error
How to solve ModuleNotFoundError: No module named 'paramiko' error  Hi, while importing following module: import paramiko I am getting the error... 'paramiko' How to solve ModuleNotFoundError: No module named 'paramiko' error
solve this
solve this   Create a student class. The student object should have studentid, studentname, subject and marks as properties. Also generate the getter and setter methods. Create 5 objects of this class and populate values
how to solve this kind of error in Eclipse IDE?
how to solve this kind of error in Eclipse IDE?   i'm creating the Simple CRUD Using Jsp, Servlet and MySQL program and i'm using the eclipse, and i all most done it, finally i'm going to run myself, it can't be run. i
hi , i cant make this programmer , can any one help me to make it pls - Java Beginners
hi , i cant make this programmer , can any one help me to make it pls  ...://www.roseindia.net/java/example/java/io/ Thanks  i want to make the whole program. i cant find delete records or update records  pls can
how to make a matrix like datagrid in ide in java pls help
how to make a matrix like datagrid in ide in java pls help  how to make a datagrid mainly matrix in ajava standalone app
Small Bug How to solve in my code
Small Bug How to solve in my code  String season=""; pst = con.prepareStatement("SELECT DISTINCT(Season) season FROM specialdates where Regid...") + ","; it shows bug in findbugs tool.. but it executes successfully how to solve
How to solve button problem - Java Beginners
How to solve button problem  I have created button (Open File Dialog) , List, JTabbedpane and MenuBar . By clicking btnBrowse button I am getting... GridLayout for showing image files because if I use other Layouts image files
How can we solve this puzzle using java ?
How can we solve this puzzle using java ?  Sachin likes sweets a lot...*3= 9 Hence total cost will be 1+6+4+18+15+9=53 What I have tried: class A { static void printSubsets(int set[]) { int n = set.length; for (int i = 0; i
How to add dynamically rows into database ?Need help pls
into the database.I have been trying to solve in for ages.Can anyone pls help me.Thanks...How to add dynamically rows into database ?Need help pls  Hi everyone, I really have a problem of insert multiple rows into the database.Now i can
ModuleNotFoundError: No module named 'dont-argue'
'dont-argue' How to remove the ModuleNotFoundError: No module named 'dont...ModuleNotFoundError: No module named 'dont-argue'  Hi, My Python... have to install padas library. You can install dont-argue python
Am using windows xp os..how to install wamp server for this os ?i have a trouble in this..
Am using windows xp os..how to install wamp server for this os ?i have a trouble in this..  i installed wamp server . i was put my wampserver is online.. but i cant open phpmyadmin in my browser. i dont know the reason.. pls
please help me solve this problem when i am create database connection using servlecontext
please help me solve this problem when i am create database connection using servlecontext  hi... I have create a database connection using servletcontext . in this code when i login first time it will exceute sucessfully
can interface solve this problem in java
this calander class. can interface solve this problem. If yes then how. pls...can interface solve this problem in java  I have a JDialog which displays the calendar [from 2010-2020], i created this in a different class
Dont Do this - Java Beginners
Dont Do this  Whenever you guys ask a question please describe your query? Otherwise you lost your time and other who are given answer to you. thanks Rajanikant
how to solve error like'java.lang.NumberFormatException: For input string: "7600113411"' this
how to solve error like'java.lang.NumberFormatException: For input string: "7600113411"' this  java.lang.NumberFormatException: For input string: "7600113411"    java.lang.NumberFormatException: For input string
pls send reply - Java Beginners
pls send reply  i get the error Error Occurred:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) how to remove
ModuleNotFoundError: No module named 'pls'
ModuleNotFoundError: No module named 'pls'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pls' How to remove the ModuleNotFoundError: No module named 'pls' error
ModuleNotFoundError: No module named 'pls'
ModuleNotFoundError: No module named 'pls'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pls' How to remove the ModuleNotFoundError: No module named 'pls' error
ModuleNotFoundError: No module named 'pls'
ModuleNotFoundError: No module named 'pls'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pls' How to remove the ModuleNotFoundError: No module named 'pls' error
pls help me it urgent
pls help me it urgent  hey, pls help me i want to know that can we call java/.bat file from plsql/proceudre /trigger
pls help me it urgent
pls help me it urgent  hey, pls help me i want to know that can we call java/.bat file from plsql/proceudre /trigger
pls help me it urgent
pls help me it urgent  hey, pls help me i want to know that can we call java/.bat file from plsql/proceudre /trigger
ModuleNotFoundError: No module named 'django-default-dont-cache'
: No module named 'django-default-dont-cache' How to remove the ModuleNotFoundError: No module named 'django-default-dont-cache' error? Thanks  ...ModuleNotFoundError: No module named 'django-default-dont-cache'  Hi

Ads