+ 2

would you like to help me to complete the module project The Greatest Number on the R . course The Greatest Number for R

The Greatest Number for R

25th Sep 2021, 4:02 AM
Bayu Prayoga
Bayu Prayoga - avatar
6 ответов
+ 6
Hi there, after reading the course over again, I found that simple solution hahha input <- readLines('stdin') x <- as.integer(input[1]) y <- as.integer(input[2]) z <- as.integer(input[3]) print(max(x, y, z))
2nd Oct 2021, 2:46 PM
Nariman Nazirov
Nariman Nazirov - avatar
+ 5
Hello. First plz show us ur attempts!
25th Sep 2021, 5:05 AM
Anurag Saikia
+ 2
The greatest number would be the maximum of a vector. Your code tries to calculate the sum of a vector. So what do you intend to do?
25th Sep 2021, 12:33 PM
Lisa
Lisa - avatar
0
Input <- readLines('stdin') x <- as.integer(input[1]) y <- as.integer(input[2]) rangeSum <- function(x, y) { s=0 for (n in x:y) s <- s + n return (s) } print(rangeSum(x, y)) but as I pressed run it say it's wrong so can you help me please
25th Sep 2021, 6:42 AM
Bayu Prayoga
Bayu Prayoga - avatar
0
Bayu Prayoga Do you mean that you must sum the total of a range of numbers? Maybe this could help. Note the inclusion of curly brackets in the for loop statement. input <- readLines('stdin') x <- as.integer(input[1]) y <- as.integer(input[2]) rangeSum <- function(x, y) { total <- 0 for(num in x:y){ total <- total + num } return (total) } print(rangeSum(x, y))
25th Sep 2021, 8:06 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
input <- readLines('stdin') x <- as.integer(input[1]) y <- as.integer(input[2]) z <- as.integer(input[3]) print(max(x, y, z))
18th Sep 2022, 1:49 PM
Kanisak Shakya
Kanisak Shakya - avatar