Even numbers are numbers whigh are divisible by 2. Therefore, the first even number is 2. A pseudocode which adds the first 100 even numbers can be written thus :
counter = 0
sum = 0
interval = 2
while counter < 100 :
sum = sum + interval
interval += 2
counter +=1
print(sum)
- A counter takes count of the number of values summed
- Initializes a variable which holds the sum of even values
- Since even numbers are divisible by 2; every factor ; increase every added value by 2
- The program ends once counter is 100
Learn more : brainly.com/question/25327166
A. hub
I can't think of a good reason to use a hub anymore, I always use a switch instead.
Answer:
In Python:
def decimalToBinary(num):
if num == 0:
return 0
else:
return(num%2 + 10*decimalToBinary(int(num//2)))
decimal_number = int(input("Decimal Number: "))
print("Decimal: "+str(decimalToBinary(decimal_number)))
Explanation:
This defines the function
def decimalToBinary(num):
If num is 0, this returns 0
<em> if num == 0:
</em>
<em> return 0
</em>
If otherwise
else:
num is divided by 2, the remainder is saved and the result is recursively passed to the function; this is done until the binary representation is gotten
return(num%2 + 10*decimalToBinary(int(num//2)))
The main begins here.
This prompts the user for decimal number
decimal_number = int(input("Decimal Number: "))
This calls the function and prints the binary representation
print("Decimal: "+str(decimalToBinary(decimal_number)))
Answer:hypertext transfer protocol secure
Explanation: