// The "LCMTest" class.
import hsa.*;
public class LCMTestDanyalM
{
// Place your lowestCommonMultiple code here
public static int lowestCommonMultiple (int firstNumber, int secondNumber)
{
/// int product = 1;
// int limit = firstNumber * secondNumber;
for (int count = 1 ; ; count++)
{
if (count % firstNumber 0)
{
return count;
}
}
}
// Do not modify the code below
public static void main (String [] args)
{
Console c = new Console ();
final int NO_OF_TEST_CASES = 1000000; // maximum of 1000000
int [] first = new int [NO_OF_TEST_CASES];
int [] second = new int [NO_OF_TEST_CASES];
int [] LCM = new int [NO_OF_TEST_CASES];
c.println ("Loading the data...");
TextInputFile inFile = new TextInputFile ("lcmdata.txt");
int index = 0;
while (!inFile.eof () && index < first.length)
{
first [index] = inFile.readInt ();
second [index] = inFile.readInt ();
LCM [index] = inFile.readInt ();
index++;
}
inFile.close ();
// Testing the correctness and speed
c.println ("Start Timing");
long startTime = System.currentTimeMillis ();
for (int nextTest = 0 ; nextTest < first.length ; nextTest++)
{
int studentLCM = lowestCommonMultiple (first [nextTest], second [nextTest]);
if (studentLCM != LCM [nextTest])
{
c.println ("Incorrect: For " + first [nextTest] +
" and " + second [nextTest] + " you got "
+ studentLCM + " for the lowest common mulitple,"
+ "\nbut the answer should be: "
+ LCM [nextTest]);
break;
}
}
long endTime = System.currentTimeMillis ();
c.print ("Total Time: ");
c.println ((endTime - startTime), 20);
c.println ("Program Complete");
} // main method
} // Perfect class
Chat with our AI personalities
380/100 finds 1 percent. * 20 = 76
EXAMPLE 1 The QBASIC program will, automatically, *capitalize* any reserved 'keyword' which it finds once you've already gone and typed in a line of code; and, then, at the end of that code line, do finally press the [RETURN/ENTER] key...to confirm what you've just gone and typed in. A keyword might be say the PRINT command statement...so, if I were to type inside of the QBASIC editor the following line of code... print 1+1 ...then, the moment I press the [RETURN/ENTER] key when I get to the end of that line...the QBASIC interpreter program will, automatically, change the 'lower case' word: print...to become all UPPERCASE, instead; QBASIC Editor will display the previous line of code I typed in as being... PRINT 1+1 ...thus, I am able to tell immediately that PRINT is a special reserved 'keyword'/or, command statement which the QBASIC program, quite clearly, recognizes and understands. This also helps me the programmer to know if I actually typed in that 'keyword' either correctly/or, incorrectly; if wrong...and, the program did NOT automatically capitalize it...; then, I know I must have either accidentally 'misspelled' the keyword/or, must otherwise have done something to go get it wrong...?! EXAMPLE 2 If I were to type in to the QBASIC Editor program the following line of code using all 'lower case' letters... x=10: if x=10 then print "ten" else print "NOT ten" ...and, then, when I've reached the end of that line of code, press [RETURN/ENTER] key to confirm my code entry; the QBASIC interpreter program will, automatically, respond by capitalizing any reseved 'keywords' that it finds; then, QBASIC Editor displays the line of code I typed in as being... x=10 : IF x=10 THEN PRINT "ten" ELSE PRINT "NOT ten" Looking at this newly capitalized line...it tells me that... IF/THEN/ELSE/PRINT...are all QBASIC reserved 'keywords'. NOTE: Whatever is a string a text that is written in between double quote marks: ("") will be totally unaffected by such capitalizing; instead, text strings will be printed out, quite literally, 'as is'. FINAL NOTE There are far too many QBASIC 'keywords' for me to go and list here; possibly, a couple hundred...! QBASIC has many 'keywords' that it uses; if you wish to see what ALL of these keywords are; then, from inside of the QBASIC Editor program itself...do a combination key press of: [SHIFT] + [F1]...and, there you will see the Help file...that shows each 'keyword' you can use to write QBASIC programs with; as well as, offering a clear explanation/it shows 'example codes' demonstrating exactly how each of these 'keywords' should be used; just do 'copy & paste'/then, RUN the program to follow these examples along.
It means expected, or awaited. To 'anticipate' something is to 'expect' it or 'predict' it in the future. For instance if someone throws you a ball you have to anticipate where it will be in order for you to catch it. Alternatively if you have done something naughty, you can anticipate that your mother will be cross when she finds out.
The factor tree finds the prime factorizations The prime factorizations find the GCF and LCM.Example 30 and 42:3015,25,3,24221,27,3,22 x 3 x 5 = 302 x 3 x 7 = 42Select the common factors.2 x 3 = 6, the GCFCombine the factors, eliminating duplicates.2 x 3 x 5 x 7 = 210, the LCMCheck it.30 x 42 = 1260210 x 6 = 1260It checks.
The basic difference between the two types of questions is: A main idea question asks for the broad definition of the topic - For example, What is Harry Potter about? You would give a general answer that tells about the story. (Its about a boy who finds out that he is a wizard.) But a detail question would want an answer that contains more information - For example, Who is Harry Potter? You would give an answer telling us about the character, his personality, where he came from, who his parents were, etc. ( Harry Potter is a young boy that finds out he is a wizard after his parents have died and has been sent to live with his relatives.) Hope that helps.