Since 7 and 9 are relatively prime, any number that is a multiple of both is a multiple of 7 x 9 = 63. There are 9 multiples of 63 less than or equal to 600, so this can be computed directly using Sum = 63(1 + 2 + ... + 9) which simplifies to Sum = 63 x 9 x (1 + 9)/2 from the formula for arithmetic series.
Most programming languages have a built-in function which returns the quotient and the remainder when dividing integers, or you can write your own. So to generalize, denote 600 by max, 7 by a, and 9 by b. Input those values first. Suppose quotient returns the quotient of an integer division.
begin
N <- quotient(max, lcm(a,b)) (* N is the number of multiples of both a and b <= max *)
sum <- lcm(a,b) * N * (1 + N)/2 (* Use the formula *)
end
This is the most efficient solution. There are other solutions that don't assume an understanding of arithmetic series. Specifically, you could write:
begin
i <- 1; sum <- 0 (* Initialize counter to 1 and sum to 0 *)
While i <= max/lcm(a,b) do
sum <- sum + i * lcm(a,b)
i++;
od
end
Algorithm: multiples input: two positive integers, m and n output: print first n multiples of m i = m; for j = 1 to n print i i = i + m; next j
To become a chartered accountant in New Zealand, three general steps must be taken. You must complete the required academic program, complete a practical experience program, and complete a chartered accountants or foundations PAS/PCE program.
I use a program called Keno Notify, it shows me the MA Keno games on my PC.. it also sends me a text message when my numbers hit!
das
Since you didn't INCLUDE the slogan, we have no idea which of these statements is true
Develop an algorithm to display all prime numbers from 2 to 100. Give both the pseudocode version and the flowchart version. Convert your pseudocode into a Java program.
Pseudocode.
T. E. Bailey has written: 'Program design with pseudocode' -- subject(s): Programming, Electronic digital computers, Electronic digitalcomputer, Pseudocode (Computer program language)
X**y
No. Pseudocode is not used to write complete programs; rather, it is an overview of what you want to achieve. For example, the following pseudocode is for a program to print a list of square roots: for i = 1 to 10 show i, i*i A specific programming language may not have a "show" command, and the structure of the "for" loop might be different; additional setup and cleanup commands may also be required in a real computer program; the purpose of this pseudoce is merely to explain, to a human, what you want to achieve. The real code, with more detail, will have to be added later.
The indentation doesn't affect the "logic" of the program, however it would make it make harder to read and the purpose of pseudocode is to be read.
The indentation doesn't affect the "logic" of the program, however it would make it make harder to read and the purpose of pseudocode is to be read.
firstly try yourself then ask others or browse internet websites etc
1. Accept the 2 numbers 2. Add the 2 numbers3. Compare answer with 54. If answer is greater than 5 subtract with 5 else give a error message.
Any of these: PRINT semicolon EMIT ; WRITE ";" etc.
Pseudocode lets a programmer lay out his intended program in a simple to understand method and run it through in his head before putting his fingers on the keyboard. Programming is a complex process and needs some degree of planning beforehand to avoid mistakes and confusion later on.
I assume you are saying pseudocode, which in that case are words in plain language with the aim to explain the code of a program or algorithm. If that's not what you meant, then sorry to disappoint.