In order to display multiples of 9 up to 500 I would use a while loop with the condition number < 500. For example: #set number to the first multiple of 9 number = 9; while number < 500: print number; #add 9 to the number number += 9; Note: I put semicolons at the end of each line out of habit. Python does not require this. Note: lines beginning with # are comments The above code will print the current value of number, then add 9 to it. It will continue to do this until number is greater than or equal to 500.
I suggest you write an outer loop, that loops through all the numbers from 1 to 50. Call the variable that controls the loop something like "number".Then, initially assume the number is a prime (with a variable such as "isprime"); and write another loop that compares whether the number is divisible by any number from 2 to number-1. Call the controlling variable "factor". If number is divisible by factor, then it is not a prime, and you can exit the loop. At the end of the inner loop, if the variable "isprime" is still true, then you print the number.
Given: All Prime numbers are odd, If a number is even it is not prime, If a number is odd and it can be divided by something other than itself or 1 it is not prime. 1.) One way to test an odd number and determine whether it is prime is to start with the number 3 and try dividing it perfectly into the odd number: For example, 27 is odd, but it can be divided by the number 3 which divides perfectly into 27 nine times. 3 x 9 = 27. So 27 is not prime. If 3 doesn't divide perfectly into the number then keep adding 2 to the factor and try dividing the number by the new factor: For example, 91 is odd, but 3 does not perfectly divide 91, so we add 2 to 3 and try dividing 91 by 5 which we know immediately will not work since 91 does not end in 0 or 5, so we add 2 more and try dividing 91 by 7. We find that 7 divides perfectly into 91 thirteen times. 7 x 13 = 91, so 91 is not prime. If you know your times tables it makes this determination easier since we can also eliminate all multiples of each number that doesn't divide perfectly into the test number. For example, since 2 doesn't divide perfectly into a prime number then all multiples of 2 (all even numbers) are not eligible as potentially divisors. If 3 doesn't divide perfectly then all multiples of 3 do not have to be tested (i.e., 9, 15, 21, 27, 33...) Last example using the above tests: Is 97 prime? Given: When I use the word "divided" I mean perfectly divided Is 97 even? No, so all multiples of 2 are eliminated from testing Can 97 be divided by 3? No, so all multiples of 3 are eliminated from testing Can 97 be divided by 5? No, so all multiples of 5 are eliminated from testing Can 97 be divided by 7? No, so all multiples of 7 are eliminated from testing Can 97 be divided by 11? No, so all multiples of 11 are eliminated from testing Can 97 be divided by 13? No, so all multiples of 13 are eliminated from testing Can 97 be divided by 17? No, so all multiples of 17 are eliminated from testing Can 97 be divided by 19? No, so all multiples of 19 are eliminated from testing Can 97 be divided by 23? No, so all multiples of 23 are eliminated from testing Can 97 be divided by 29? No, so all multiples of 29 are eliminated from testing Can 97 be divided by 31? No, so all multiples of 31 are eliminated from testing We can safely say that 97 is prime at this point. Why? Because the next number to test is 37 and since 37 x 3 is 111 and we cannot divide 97 by 3 then no larger number will work. All factors have been effectively tested, albeit the slow way, but it works 100% of the time to determine primeness. Larger numbers may cause this method to be too time consuming; a formula used with a calculator would best be implemented to calculate primeness with larger numbers. You could also print out a prime number table as a reference.
1 PRINT "Kindly enter your next number, Master, or 'x' to end and total them up." 2 INPUT a$: IF a$ = "x" or a$ = "X" then GOTO 10 3 K = VAL(a$) 4 If K<0 then neg=neg+1: PRINT: GOTO 1 5 If K>0 then pos=pos+1: PRINT: GOTO 1 6 If K=0 then Z=z+1: PRINT: GOTO 1 10 PRINT: PRINT "Thank you, Master. I cannot express the joy that this exercise has brought me. Here are your results: " 11 PRINT: PRINT "The number of positive numbers you entered was "; pos; "." 12 PRINT: PRINT "The number of negative numbers you entered was "; neg; "." 13 PRINT: PRINT "The number of zeros you entered was "; Z; "." 15 PRINT: PRINT: PRINT "Would you like to play again, Master ?" 16 PRINT "Kindly touch 'x' if no, or any other key if yes. I can hardly wait." 17 Input a$: IF a$ <> "X" and a$ <> "x" then GOTO 20 18 PRINT: PRINT "It has been my pleasure to cavort with you today, Master." 19 PRINT "Y'all come back now, y'hear !" : END 20 PRINT: CLS: PRINT "Oh GOODY! I love this game!" 21 pos=0: neg=0: Z=0 22 GOTO 1
yo yo as
how to print "square" using for loop
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
answer:32 programme to print factorial of a given number in c languages
In order to display multiples of 9 up to 500 I would use a while loop with the condition number < 500. For example: #set number to the first multiple of 9 number = 9; while number < 500: print number; #add 9 to the number number += 9; Note: I put semicolons at the end of each line out of habit. Python does not require this. Note: lines beginning with # are comments The above code will print the current value of number, then add 9 to it. It will continue to do this until number is greater than or equal to 500.
Use the following:awk 'END { print NR }'Awk will count the lines and print it out.
3
first sort the ten numbers in descending order and print the first number. That will be the largest no
Why are you posting a question to do with finger print identification in several computer programming wikies.
Depending on language, here's an example: for i=4 to 120 step 4 print i next
Because you would need an infinite length of paper to print out the ticket.
One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.
Each finger has a different print. Prints are not genetic. Not even twins have the same prints.