for

How to calculate perfect numbers quickly?

I am trying to perform an exercise to show the perfect numbers present within a certain range, but I can only perform such a ... {6, 28, 496, 8128, 33550336, 8589869056, ...} After the 4th number. No I can show more. Any optimization tips for my code?

need help to calculate the factorial in ascending and descending order in an equation!

I need to solve this question: Make a program that reads the number of terms and a positive value for X. calculate and show ... um; for (int i = (num-1); i > 1; i--) { resultado = resultado * i; } return resultado; } Thanks for the help!

How to create a for in R with the indexes of a data frame

If I have a date.frame: > dato<-as.data.frame(matrix(1:64,8,8,T))[-3,] > dato V1 V2 V3 V4 V5 V6 V7 V8 1 1 2 3 ... 59 60 61 62 63 64 How can I "call" the index vector (1, 2, 4, 5, 6, 7, 8)? Because I want to use it as an index in a for.

C: tie stop condition For

Hello, could someone please explain to me what is going on in this for loop stop condition? #include <stdio.h> int mai ... put is: 34 42 -12 984 86 14 1 7 136112 I believe values from 14 are probably " crap in the memory". But why does this happen?

How to use value of i in for in a function?

I have the following code: select = Select(driver.find_element_by_id('Identificador')).select_by_visible_text('Maio/2019') f ... m[@name='Formulario']/input[@type='submit'][@value='Ok']").click() How do I replace "May / 2019" with month and year values?

Check the amount of negative elements in a JS array

I'm starting the JavaScript studies and I come across an issue where I need to identify negative elements in an array and ret ... Posit; return quantidade.length - somaDeElementosNeg.length;; } else { return 0; } } }

Can you do the for in 1 line?

The following code did not work: rank = [1, 2, 3, 4] print(rank[c] for c in range(4)) If you have how to do in a line I would like to know.

How to loop for 2 in 2?

My solution: function passandoPelosPares() { for (var i=0; i <=6; i++) console.log ('aqui eu tenho o valor de' + i) } ... tenho o valor de 0 aqui eu tenho o valor de 2 aqui eu tenho o valor de 4 aqui eu tenho o valor de 6 What am I doing wrong?

C++ (basic): for, references and syntax

My teacher presented this function to US: void escala(std::vector<double> &v, double fator) { for (auto & ... o well that I am with doubt 1. I did not find anything on the internet about, always appears the standard syntax 'for (;;)'.

Python-Tabular exercise-for-Matrix

Good Night! I'm trying to create a tabular program using for and array, my code is like this at the moment: Def crie_matrix ... = 10] This is what I want to receive, but not just from the 1 tab, but the complete tab, side by side. Someone can help me.

Pascal's Triangle is in for Infinity

I'm making a code that generates a Pascal triangle for a project of mine, but when I squeegee it gets stuck, as if it were in ... number" id="inp"> <button type="button" id="uau">UAU</button> </form> </body> </html>

How to create alphabetical list of letters in PHP according to variable number

I need to create a list of letters in alphabetical order, according to the variable N nalternatives, for example: $alternativas = 3; aí preciso criar: a b c Ifal nalternatives is 2, then it's just a, b, and so on How can I do this?

Separating even and odd numbers with two vectors in C

I have the following problem: I need to read several numbers until the number typed is 0 or any of the vectors is fully fille ... (impares < 10)); for (i=0; i<10; i++){ printf("\n Pares: %d", par[i]); printf("\n Impares: %d", impar[i]); } }

Calculate change and display notes available with JavaScript

I have a class activity to do, where I must receive from the user the amount of the purchase and the amount paid, and then di ... </form> <script type="text/javascript" src="troco.js"></script> </body> </html>

What is underscore (or underline) for in the replay structure?

What does this _ do? Why is it being used in the following code snippet? print('3 numeros') data = [] for _ in range(3): data.append(input()) numbers = list(map(int, data)) print(numbers)

Factorial from 0 to 20 using For

I need to do the following exercise: "Using the For loop, calculate and print on screen the factorial of all numbers between ... fat = fat * cf; acc = acc + fat; } } printf("%d! = %.1lf\n",cc+1 , fat); } }

How to implement cosine function using Taylor series in Python?

Guys, I'm having the following problem: Until then I did the following code: import math def cos(x, n): soma = 1 ... n) for i in range(n): soma += formula return soma Can anyone tell if it's correct? If not, how do I fix it?

Syntax of for in C

I'm new to the community, and I recently noticed in a C code, a repeat loop for, with the following syntax. for(;;). Someone would know how to explain this syntax to me. I appreciate it now.

Variable loses value inside the " for"

a=2 for a in range (9) : print (a+1) Why using for, in this case, is printed from 1 to 9, and the variable a is equal to 2?

Finding multiple fulgaps

The purpose of the program is to show only the numbers fulgaps from 0 to 999, a number that must be divisible by the concaten ... 0) { std::cout << Number << std::endl; Number++; } } return 0; }