## fibonacci sequence works, but returns results I do not expect

nterms = int(input("How many terms? ")) n1 = 0 n2 = 1 count = 0 if nterms <= 0: print("Please enter a positive integer") elif nterms == 1: print("Fibonacci sequence upto",nterms,":") print(n1) else: print("Fibonacci sequence upto",n...
more »

## Sorting integers into 3 equal (almost) groups

So I have this problem which I need to solve, I have a group of integers which I want to sort into 3 equal groups. The data which I need to sort is: 3169, 3063, 3061, 3054, 3018, 3013, 2979, 2943, 2833, 2824, 2794, 2759, 2722, 2701, 2602, 2594, 2...
more »

## How do I convert each element of a string array to an integer? (VB)

For my current task I have to read in an 8 digit card number using an array. I have declared my array as this at the beginning of my code: Dim LoyaltyCardDigits(8) As Integer The reason I declared this as an integer is because I need to carry out ...
more »

## Homework Help - Reading code and counting integers

I need some assistance trying to grasp a concept that our teacher is trying to get across. This is a beginning VBA Access course and we have just coded our first simple project. Unfortunately, I am unsure if I am not grasping the concept because he's...
more »

## What is 32-bit integer in Javascript?

I was doing some coding challenge and encountered something I am not too familiar with. I am more curious to learn what it is and why it is there. The prompt it pretty straightforward: Given a 32-bit signed integer, reverse digits of an integer. Ex...
more »

## Django - ChoiceField cleaned_data gets String instead of Integer

I have a form field called 'units' like this: units = forms.ChoiceField(choices=[(x, x) for x in range(1, 11)], help_text = 'Units: ') When I do form.cleaned_data['units'] I get a String instead of an Integer. How can I change the field to ge...
more »

## Convert RDD values in KVP to integers in PySpark

I am trying to convert the column[2] values in my RDD key-value pairs from strings to integers so that I am able to sum them up and calculate an average. I attempted to have column [2] automatically display as integers during the mapping phase but I...
more »

## Modulo operator in R functions differently on non-integers

When using the modulo operator, %%, I noticed it functions differently on non-integers, e.g. 60 %% 5 -> 0 0.60 %% 0.05 -> 0.05 # ??? When using the floor-function instead, I get a similar result: floor(60/5) -> 12 floor(0.60/0.05) ->...
more »

## How do you change a specific element of a set?

In this code, I am trying to compare the value of a set that has been looped each time to a value passed (in this case a) in a parameter. What's interesting though is that it shows when I use a for each loop that each element is an integer. How do I ...
more »

## How to add two columns in MATLAB?

I am trying to create a simple text file from a MATLAB script that is ordered in the following matter that illustrates a classroom's grade throughout the semester. There are 20 entries for the 20 students enrolled, with 5 homework entries, a midterm ...
more »

## Error in : invalid program counter value: 0x00000000

I have an assignment to take in an integer from the user, and output it as a string of chars (in MIPS). I am using MARS, and am receiving the error: invalid program counter value: 0x00000000. I have seen others ask this question, but the answ...
more »

## Extract int value and string from string

I would like to use string class, to extract some information from the string. Given the string: <12,Apple>,<20,Orange>,<49,iPhone> I would like to let 12, 20, 49 to a int array. that means a[0] = 12, a[1] = 20, a[2] = 49. And let Apple, O...
more »

## Java - Adding up integers from a file

I'm having problems with adding integers that are in a file. The code works fine displaying the integers but as soon as I add "total += scanner.nextInt();" it skips every other integer (e.g if file contained - 10, 20, 30, 40, 50, it would only displa...
more »

## Integer division in C with unsigned short

I feel like the bloodiest beginner - Why does the following not work: // declarations unsigned short currentAddr= 0x0000; unsigned short addr[20] = {1, 0}; // main addr[1] = (~currentAddr)/2+1; printf("addr[1] wert: %hu\n", addr[1]); // equals 1, ...
more »

## convert a list of long to a list of int java 8

I have a method which takes a list of integer as parameter. I currently have a list of long and want to convert it to a list of integer so I wrote : List<Integer> student = studentLong.stream() .map(Integer::valueOf) .collect(Collecto...
more »

## Remove line from JTextArea

I have a JTextArea that is filled with numbers with no duplicates. There is an add and remove button. I have programmed the add button, but I am struggling with programming the remove button. I know how to remove the number from the array, but I'm no...
more »

## specifying which numbers to use with as.numeric() function in R

I wanna convert a column with three different character values to numeric. the column is long but the head is: Yes No No Maybe No Yes I want it to look like this: 2 1 1 3 1 2 the problem is that I wanna specify which value would get which numb...
more »

## Converting an Integer to a Drawable

I have two Adapter classes and in the first one, i have an Array of Integers[] named mThumbIds which is initialized like this : // References to our images private Integer[] mThumbIds = { R.mipmap.beyondthe_ferocious_flash_majin_vegeta_i...
more »

## Double not storing number in C (is the number too small)

This is my issue, i need to calculate how many clock cycles are in a ms and us for my pll waits on a TM4C123. However the values are coming out as zero on my double making my other values incorrect. Any help would be much appreciated. #include <s...
more »

## The value of my integers is not showing in my black jack program c#

I am trying to complete a very simple black jack program. What I seem to having trouble with is the fact that there are no numbers being generated for card one and two. This is my code so far: namespace Black_Jack { class Program { static void...
more »

## print out total of integer after converted from char to integer inside stack

My program requires me to convert char inside a variable to integer and then do adding of large numbers, with the same length. But after line "while (!mystack1.empty() && !mystack2.empty()).." it doesnt print out anything my I know what is th...
more »

## converting from string to float or integer depending on their nature in python

After parsing a file, I obtain a list of strings containing numerical values, let's say: my_list = ['1', '-2.356', '00.57', '0', '-1', '02678', '0.005367', '0', '1'] In order to obtain these numerical values, I do the following: new_list = [float...
more »

## Extend Int enum with comparison operators

Very often you have Int enums like this: enum Difficulty: Int { case Easy = 0 case Normal case Hard } Difficulty values have a certain meaning and we may want to introduce order for them. For example, somewhere we need to compare: let...
more »

## Function is not being called after input assigns a value (Python)

I have a small file with a bunch of phrases on each line. I want the user to type a number and that number will print the selected line. def printSpecLine(x): print('started') with open('c:/lab/save.txt') as f: for i, line in enumera...
more »

## Python: User enters number, then a letter, then outputs the letter the amount of times as the number says

Python: User enters number, then a letter, then outputs the letter the amount of times as the number says: for example "Enter Integer": 4 "Enter Letter": a OUTPUT a a a a This is what I currently have, but I get name error, ' ' is not defined,...
more »

## What does the 'I' suffix means?

unsigned a = 5; int b = a - 1I; printf("b=%d", b); Run these codes on Android/iOS, you will get a wield result like "b=5". What does the 'I' suffix means? ...
more »

## C++ return type of +, - and * operators on integral types

I wonder how the return type of +, - and * works on integral types in C++. Using typeid from #include <typeinfo> to check the return type of each operation (and c++filt -t to make it human readable), here few examples unsigned char + unsigne...
more »

## Typecasting in Python to Integer

L = int(input()) N = int(input()) W, H = int(input().split(" ")) for num in range(N): if (W < L or H < L): print("UPLOAD other")][1] https://i.stack.imgur.com/xgtoS.jpg ...
more »

## Final Grade Calculator in java

This is a personal project, just trying to create a program to calculate my final grade and to the best of my knowledge I thought I did everything right, here is my entire program updated with working code: FinalGradeCalculator: import java.io.*; i...
more »

## Why is my Integer.parseInt not working?

The assignment is to create an output that reads from a file and outputs the information that is stated in the program. It was working perfectly before I went back and added the patientNumber string and the first for loop that deals with patientNumbe...
more »

## How to find the sum of n odd integers starting from 1?

Today I had an interview and I had no idea how to answer this question... Give a recursive algorithm finding the sum of the first n odd positive integers. For Example: If n=3 then the positive integers are 1+3+5 with a sum of 9. ...
more »

## Find all two-valued numbers representable as the sum of the roots of two natural numbers

Task is to find all two-valued numbers representable as the sum of the roots of two natural numbers using list's generator and print all these combinations + length of list. I got this: import Data.List func = filter (>9) (takeWhile (<100) (n...
more »

## how to extract a number from text file (or do a query on a site to get that number to bat file

I'm trying to write a bat file that would use output of https://www.feathercoin.com/netstats/ I need current network difficulty I used curl to extract the contents of the webpage and findstr to write output of a string that contains difficulty to...
more »

## SQL unexpected result when mixing numbers and strings

I have no idea why this happens. Sql statement below returns 'test2'. Why does it do that? It seems like it only captures the first number of the string I gave. I expected an empty result. Query: SELECT article FROM news WHERE id = '2aas13' Tabl...
more »