Apply f(x)=2x+1 Twice
PHP
Medium
3 views
Problem Description
Given x, apply f(x)=2x+1 two times and print the result.
Input Format
One integer x.
Output Format
One integer.
Official Solution
<?php
$inputText=trim(stream_get_contents(STDIN));
if($inputText==='') exit;
$x=intval($inputText);
function f($x){ return $x*2+1; }
$x=f(f($x));
echo $x;
?>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!